cliskill 1.0.4 → 1.0.6
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/README.md +66 -0
- package/dist/bootstrap/cli.js +1 -1
- package/dist/{chunk-UJMUL64T.js → chunk-S4ZZPUPF.js} +1595 -159
- package/dist/chunk-S4ZZPUPF.js.map +1 -0
- package/dist/index.d.ts +249 -63
- package/dist/index.js +46 -313
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-UJMUL64T.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { runCli } from './bootstrap/cli.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { ChildProcess } from 'node:child_process';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
3
5
|
import React from 'react';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -242,6 +244,31 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
242
244
|
maxMemorySize?: number | undefined;
|
|
243
245
|
idleThreshold?: number | undefined;
|
|
244
246
|
}>>;
|
|
247
|
+
/** MCP servers — external tool providers via Model Context Protocol */
|
|
248
|
+
mcpServers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
249
|
+
/** Unique name for this MCP server */
|
|
250
|
+
name: z.ZodString;
|
|
251
|
+
/** Command to start the MCP server process */
|
|
252
|
+
command: z.ZodString;
|
|
253
|
+
/** Arguments passed to the command */
|
|
254
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
255
|
+
/** Environment variables for the server process */
|
|
256
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
257
|
+
/** Transport type (currently only stdio supported) */
|
|
258
|
+
transport: z.ZodDefault<z.ZodEnum<["stdio"]>>;
|
|
259
|
+
}, "strip", z.ZodTypeAny, {
|
|
260
|
+
name: string;
|
|
261
|
+
command: string;
|
|
262
|
+
args: string[];
|
|
263
|
+
transport: "stdio";
|
|
264
|
+
env?: Record<string, string> | undefined;
|
|
265
|
+
}, {
|
|
266
|
+
name: string;
|
|
267
|
+
command: string;
|
|
268
|
+
args?: string[] | undefined;
|
|
269
|
+
env?: Record<string, string> | undefined;
|
|
270
|
+
transport?: "stdio" | undefined;
|
|
271
|
+
}>, "many">>;
|
|
245
272
|
}, "strip", z.ZodTypeAny, {
|
|
246
273
|
providers: {
|
|
247
274
|
name: string;
|
|
@@ -305,6 +332,13 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
305
332
|
maxMemorySize: number;
|
|
306
333
|
idleThreshold: number;
|
|
307
334
|
};
|
|
335
|
+
mcpServers: {
|
|
336
|
+
name: string;
|
|
337
|
+
command: string;
|
|
338
|
+
args: string[];
|
|
339
|
+
transport: "stdio";
|
|
340
|
+
env?: Record<string, string> | undefined;
|
|
341
|
+
}[];
|
|
308
342
|
defaultProvider?: string | undefined;
|
|
309
343
|
systemPrompt?: string | undefined;
|
|
310
344
|
}, {
|
|
@@ -372,6 +406,13 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
372
406
|
maxMemorySize?: number | undefined;
|
|
373
407
|
idleThreshold?: number | undefined;
|
|
374
408
|
} | undefined;
|
|
409
|
+
mcpServers?: {
|
|
410
|
+
name: string;
|
|
411
|
+
command: string;
|
|
412
|
+
args?: string[] | undefined;
|
|
413
|
+
env?: Record<string, string> | undefined;
|
|
414
|
+
transport?: "stdio" | undefined;
|
|
415
|
+
}[] | undefined;
|
|
375
416
|
}>;
|
|
376
417
|
type AppConfig = z.infer<typeof appConfigSchema>;
|
|
377
418
|
|
|
@@ -508,6 +549,11 @@ type LoopEvent = {
|
|
|
508
549
|
type: 'tool_start';
|
|
509
550
|
toolName: string;
|
|
510
551
|
toolId: string;
|
|
552
|
+
} | {
|
|
553
|
+
type: 'tool_progress';
|
|
554
|
+
toolName: string;
|
|
555
|
+
toolId: string;
|
|
556
|
+
message: string;
|
|
511
557
|
} | {
|
|
512
558
|
type: 'tool_result';
|
|
513
559
|
toolName: string;
|
|
@@ -545,6 +591,8 @@ interface ToolExecutionContext {
|
|
|
545
591
|
checkPermission: (operation: string, details?: string) => Promise<boolean>;
|
|
546
592
|
/** Session identifier for per-session state isolation */
|
|
547
593
|
sessionId?: string;
|
|
594
|
+
/** P0.2: Progress callback — tools emit intermediate status messages */
|
|
595
|
+
onProgress?: (message: string) => void;
|
|
548
596
|
}
|
|
549
597
|
|
|
550
598
|
/** Risk level of a tool operation */
|
|
@@ -553,16 +601,22 @@ type RiskLevel = 'readonly' | 'safe' | 'destructive' | 'critical';
|
|
|
553
601
|
interface ToolContract {
|
|
554
602
|
/** Unique name of the tool */
|
|
555
603
|
name: string;
|
|
604
|
+
/** Alternative names for the tool (backward-compatible aliases) */
|
|
605
|
+
aliases?: string[];
|
|
556
606
|
/** Description shown to the AI model */
|
|
557
607
|
description: string;
|
|
608
|
+
/** Short hint for tool search/discovery */
|
|
609
|
+
searchHint?: string;
|
|
558
610
|
/** Zod schema for input validation */
|
|
559
611
|
inputSchema: z.ZodType;
|
|
560
612
|
/** Risk level — determines permission requirements */
|
|
561
613
|
riskLevel: RiskLevel;
|
|
562
|
-
/** Whether this tool can run concurrently with other tools */
|
|
563
|
-
concurrencySafe: boolean;
|
|
614
|
+
/** Whether this tool can run concurrently with other tools (static or dynamic per-input) */
|
|
615
|
+
concurrencySafe: boolean | ((input: Record<string, unknown>) => boolean);
|
|
564
616
|
/** Whether this tool only reads data (no side effects) */
|
|
565
617
|
readOnly: boolean;
|
|
618
|
+
/** Maximum output chars before truncation (default: 50_000) */
|
|
619
|
+
maxResultSizeChars?: number;
|
|
566
620
|
/**
|
|
567
621
|
* Execute the tool with validated input.
|
|
568
622
|
* Returns a string result to be sent back to the model.
|
|
@@ -601,19 +655,22 @@ declare abstract class BaseTool<T extends z.ZodType> implements ToolContract {
|
|
|
601
655
|
*/
|
|
602
656
|
declare class ToolRegistry {
|
|
603
657
|
private tools;
|
|
604
|
-
|
|
658
|
+
private aliasMap;
|
|
659
|
+
/** Register a tool (with optional aliases) */
|
|
605
660
|
register(tool: ToolContract): void;
|
|
606
|
-
/** Get a tool by name */
|
|
661
|
+
/** Get a tool by name or alias */
|
|
607
662
|
get(name: string): ToolContract | undefined;
|
|
608
663
|
/** Get all registered tools */
|
|
609
664
|
getAll(): ToolContract[];
|
|
610
665
|
/** Get tool definitions for AI model requests */
|
|
611
666
|
getToolDefinitions(): ToolDefinition[];
|
|
612
|
-
/** Check if a tool exists */
|
|
667
|
+
/** Check if a tool exists (by name or alias) */
|
|
613
668
|
has(name: string): boolean;
|
|
614
|
-
/**
|
|
669
|
+
/** Search tools by keyword in name, description, or searchHint */
|
|
670
|
+
search(keyword: string): ToolContract[];
|
|
671
|
+
/** Unregister a tool (and its aliases) */
|
|
615
672
|
unregister(name: string): void;
|
|
616
|
-
/** Clear all tools */
|
|
673
|
+
/** Clear all tools and aliases */
|
|
617
674
|
clear(): void;
|
|
618
675
|
}
|
|
619
676
|
|
|
@@ -677,6 +734,10 @@ type TaskCategory = 'reasoning' | 'code' | 'fast' | 'creative' | 'analysis' | 'd
|
|
|
677
734
|
interface ModelRouterConfig {
|
|
678
735
|
/** Default model/alias to use when no specific model is requested */
|
|
679
736
|
defaultModel: string;
|
|
737
|
+
/** Fallback model/alias when primary fails (529/503/overloaded) */
|
|
738
|
+
fallbackModel?: string;
|
|
739
|
+
/** Ordered list of fallback models — tried sequentially on failure */
|
|
740
|
+
fallbackChain?: string[];
|
|
680
741
|
/** Model preferences per task category */
|
|
681
742
|
preferences: Partial<Record<TaskCategory, string>>;
|
|
682
743
|
}
|
|
@@ -701,6 +762,36 @@ declare class ModelRouter {
|
|
|
701
762
|
}>;
|
|
702
763
|
/** Get the effective model name for a given alias or name */
|
|
703
764
|
getEffectiveModel(requestedModel?: string): string;
|
|
765
|
+
/**
|
|
766
|
+
* Resolve with fallback: if primary adapter fails (529/503/overloaded),
|
|
767
|
+
* try the fallback model. Returns both adapters for retry logic.
|
|
768
|
+
*/
|
|
769
|
+
resolveWithFallback(primaryModel?: string): {
|
|
770
|
+
primary: ProviderAdapter | null;
|
|
771
|
+
fallback: ProviderAdapter | null;
|
|
772
|
+
};
|
|
773
|
+
/**
|
|
774
|
+
* Build the full fallback chain for a given primary model.
|
|
775
|
+
* Returns adapters in priority order: [primary, ...fallbackChain].
|
|
776
|
+
* Skips duplicates and null entries.
|
|
777
|
+
*/
|
|
778
|
+
resolveFallbackChain(primaryModel?: string): ProviderAdapter[];
|
|
779
|
+
/**
|
|
780
|
+
* Stream with automatic fallback on overloaded errors.
|
|
781
|
+
* Tries each adapter in the fallback chain until one succeeds.
|
|
782
|
+
* Yields a mix of the primary response or fallback response events.
|
|
783
|
+
*/
|
|
784
|
+
streamWithFallback(request: CompletionRequest, primaryModel?: string): AsyncGenerator<StreamEvent>;
|
|
785
|
+
/**
|
|
786
|
+
* Complete with automatic fallback on overloaded errors.
|
|
787
|
+
* Tries each adapter in the fallback chain until one succeeds.
|
|
788
|
+
*/
|
|
789
|
+
completeWithFallback(request: CompletionRequest, primaryModel?: string): Promise<{
|
|
790
|
+
result: CompletionResult;
|
|
791
|
+
usedModel: string;
|
|
792
|
+
}>;
|
|
793
|
+
/** Find an alternative adapter different from the excluded one */
|
|
794
|
+
private findAlternativeAdapter;
|
|
704
795
|
private findAdapterForModel;
|
|
705
796
|
}
|
|
706
797
|
|
|
@@ -1252,6 +1343,75 @@ declare class AgentTool extends BaseTool<typeof agentInputSchema> {
|
|
|
1252
1343
|
execute(input: AgentInput, context: ToolExecutionContext): Promise<string>;
|
|
1253
1344
|
}
|
|
1254
1345
|
|
|
1346
|
+
type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
1347
|
+
interface Task {
|
|
1348
|
+
id: string;
|
|
1349
|
+
name: string;
|
|
1350
|
+
description: string;
|
|
1351
|
+
type: 'agent' | 'shell' | 'custom';
|
|
1352
|
+
status: TaskStatus;
|
|
1353
|
+
progress: number;
|
|
1354
|
+
result: string | null;
|
|
1355
|
+
error: string | null;
|
|
1356
|
+
output: string;
|
|
1357
|
+
exitCode: number | null;
|
|
1358
|
+
createdAt: number;
|
|
1359
|
+
completedAt: number | null;
|
|
1360
|
+
/** Shell command (for shell tasks started via startTask) */
|
|
1361
|
+
command: string;
|
|
1362
|
+
/** Command arguments (for shell tasks started via startTask) */
|
|
1363
|
+
args: string[];
|
|
1364
|
+
/** Running child process (only for shell tasks started via startTask) */
|
|
1365
|
+
process?: ChildProcess;
|
|
1366
|
+
}
|
|
1367
|
+
interface TaskCreateOptions {
|
|
1368
|
+
name: string;
|
|
1369
|
+
description: string;
|
|
1370
|
+
type: 'agent' | 'shell' | 'custom';
|
|
1371
|
+
}
|
|
1372
|
+
type EventMap = {
|
|
1373
|
+
onProgress: [taskId: string, progress: number, message?: string];
|
|
1374
|
+
onComplete: [taskId: string, result: string];
|
|
1375
|
+
onError: [taskId: string, error: string];
|
|
1376
|
+
onStatusChange: [taskId: string, status: TaskStatus];
|
|
1377
|
+
};
|
|
1378
|
+
/**
|
|
1379
|
+
* TaskManager — manages background tasks with event emission.
|
|
1380
|
+
* Supports both generic tasks (via createTask) and shell tasks (via startTask).
|
|
1381
|
+
*/
|
|
1382
|
+
declare class TaskManager extends EventEmitter {
|
|
1383
|
+
private tasks;
|
|
1384
|
+
private completedOrder;
|
|
1385
|
+
/** Create a generic task entry (for agent/shell tasks via executor) */
|
|
1386
|
+
createTask(options: TaskCreateOptions): string;
|
|
1387
|
+
/** Start a shell task with a spawned child process */
|
|
1388
|
+
startTask(command: string, args?: string[], cwd?: string): Task;
|
|
1389
|
+
getTask(id: string): Task | undefined;
|
|
1390
|
+
stopTask(id: string): boolean;
|
|
1391
|
+
/** Update task status (for agent/shell tasks via executor) */
|
|
1392
|
+
updateStatus(id: string, status: TaskStatus): void;
|
|
1393
|
+
/** Update task progress percentage (for agent tasks) */
|
|
1394
|
+
updateProgress(id: string, progress: number, message?: string): void;
|
|
1395
|
+
/** Cancel a task (for agent/shell tasks via executor) */
|
|
1396
|
+
cancelTask(id: string): void;
|
|
1397
|
+
/** Set error result on a task */
|
|
1398
|
+
setError(id: string, error: string): void;
|
|
1399
|
+
/** Set success result on a task */
|
|
1400
|
+
setResult(id: string, result: string): void;
|
|
1401
|
+
/** Remove a completed/failed/cancelled task */
|
|
1402
|
+
removeTask(id: string): void;
|
|
1403
|
+
/** Clear all completed/failed/cancelled tasks */
|
|
1404
|
+
clearCompleted(): void;
|
|
1405
|
+
/** Count of active (pending + running) tasks */
|
|
1406
|
+
getActiveCount(): number;
|
|
1407
|
+
listTasks(filter?: {
|
|
1408
|
+
status?: TaskStatus;
|
|
1409
|
+
} | TaskStatus): Task[];
|
|
1410
|
+
/** Type-safe event listener */
|
|
1411
|
+
on<E extends keyof EventMap>(event: E, listener: (...args: EventMap[E]) => void): this;
|
|
1412
|
+
private evictOldTasks;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1255
1415
|
/** A memory entry stored in the memory system */
|
|
1256
1416
|
interface MemoryEntry {
|
|
1257
1417
|
/** Unique ID */
|
|
@@ -1446,27 +1606,49 @@ interface PermissionResult {
|
|
|
1446
1606
|
allowed: boolean;
|
|
1447
1607
|
reason?: string;
|
|
1448
1608
|
}
|
|
1609
|
+
/** Auto-approve rule pattern */
|
|
1610
|
+
interface AutoApprovePattern {
|
|
1611
|
+
/** Tool name or glob pattern */
|
|
1612
|
+
tool: string;
|
|
1613
|
+
/** Content regex pattern for auto-approval */
|
|
1614
|
+
inputPattern?: RegExp;
|
|
1615
|
+
/** Max risk level to auto-approve */
|
|
1616
|
+
maxRiskLevel?: RiskLevel;
|
|
1617
|
+
}
|
|
1449
1618
|
/**
|
|
1450
1619
|
* Permission manager that evaluates tool execution requests
|
|
1451
|
-
* against configured rules and the current permission mode.
|
|
1620
|
+
* against configured rules, auto-approve patterns, and the current permission mode.
|
|
1621
|
+
* P3.13: Enhanced with dynamic permission checking, auto-approve patterns, and caching.
|
|
1452
1622
|
*/
|
|
1453
1623
|
declare class PermissionManager {
|
|
1454
1624
|
private mode;
|
|
1455
1625
|
private rules;
|
|
1456
1626
|
private sessionDecisions;
|
|
1457
|
-
|
|
1627
|
+
private autoApprovePatterns;
|
|
1628
|
+
private decisionCache;
|
|
1629
|
+
private cacheTtl;
|
|
1630
|
+
constructor(mode: PermissionMode, rules?: PermissionRule[], autoApprovePatterns?: AutoApprovePattern[]);
|
|
1631
|
+
/**
|
|
1632
|
+
* P3.13: Dynamic permission check — evaluates tool + input together.
|
|
1633
|
+
* Uses auto-approve patterns for regex-based matching.
|
|
1634
|
+
*/
|
|
1635
|
+
canUseTool(toolName: string, input: Record<string, unknown>, riskLevel: RiskLevel): PermissionResult;
|
|
1458
1636
|
/**
|
|
1459
1637
|
* Check if a tool operation is allowed.
|
|
1460
1638
|
*/
|
|
1461
1639
|
check(toolName: string, riskLevel: RiskLevel, content?: string): PermissionResult;
|
|
1462
1640
|
/**
|
|
1463
|
-
* Record a user decision for the session.
|
|
1641
|
+
* Record a user decision for the session with caching.
|
|
1464
1642
|
*/
|
|
1465
1643
|
recordDecision(toolName: string, content: string, allowed: boolean): void;
|
|
1466
1644
|
/**
|
|
1467
1645
|
* Add a permission rule.
|
|
1468
1646
|
*/
|
|
1469
1647
|
addRule(rule: PermissionRule): void;
|
|
1648
|
+
/**
|
|
1649
|
+
* P3.13: Add an auto-approve pattern.
|
|
1650
|
+
*/
|
|
1651
|
+
addAutoApprovePattern(pattern: AutoApprovePattern): void;
|
|
1470
1652
|
/**
|
|
1471
1653
|
* Set the permission mode.
|
|
1472
1654
|
*/
|
|
@@ -1477,6 +1659,7 @@ declare class PermissionManager {
|
|
|
1477
1659
|
getMode(): PermissionMode;
|
|
1478
1660
|
private matchTool;
|
|
1479
1661
|
private matchContent;
|
|
1662
|
+
private riskLevelOrdinal;
|
|
1480
1663
|
}
|
|
1481
1664
|
|
|
1482
1665
|
/**
|
|
@@ -1526,12 +1709,27 @@ interface CostConfig {
|
|
|
1526
1709
|
cacheWrite: number;
|
|
1527
1710
|
}>;
|
|
1528
1711
|
budgetLimit?: number;
|
|
1712
|
+
/** Warning thresholds (0-1) — triggers onBudgetWarning callback */
|
|
1713
|
+
warningThreshold?: number;
|
|
1714
|
+
/** Critical threshold (0-1) — triggers onBudgetCritical callback */
|
|
1715
|
+
criticalThreshold?: number;
|
|
1716
|
+
}
|
|
1717
|
+
type BudgetLevel = 'normal' | 'warning' | 'critical' | 'exceeded';
|
|
1718
|
+
interface BudgetStatus {
|
|
1719
|
+
level: BudgetLevel;
|
|
1720
|
+
used: number;
|
|
1721
|
+
limit?: number;
|
|
1722
|
+
percent: number;
|
|
1723
|
+
remainingBudget?: number;
|
|
1529
1724
|
}
|
|
1530
1725
|
declare class CostTracker {
|
|
1531
1726
|
private entries;
|
|
1532
1727
|
private config;
|
|
1533
1728
|
private sessionStart;
|
|
1729
|
+
private lastBudgetLevel;
|
|
1534
1730
|
constructor(config?: Partial<CostConfig>);
|
|
1731
|
+
/** Find prices for a model — exact match first, then fuzzy pattern matching */
|
|
1732
|
+
private findPrices;
|
|
1535
1733
|
/** Record token usage for a model */
|
|
1536
1734
|
recordUsage(model: string, usage: Omit<ModelUsage, 'model' | 'totalRequests'>): CostEntry;
|
|
1537
1735
|
/** Get total session cost in USD */
|
|
@@ -1551,6 +1749,24 @@ declare class CostTracker {
|
|
|
1551
1749
|
limit?: number;
|
|
1552
1750
|
percent?: number;
|
|
1553
1751
|
};
|
|
1752
|
+
/**
|
|
1753
|
+
* Get detailed budget status with warning levels.
|
|
1754
|
+
* Returns current budget level and whether it changed since last check.
|
|
1755
|
+
*/
|
|
1756
|
+
getBudgetStatus(): BudgetStatus;
|
|
1757
|
+
/**
|
|
1758
|
+
* Check if budget level changed since last call.
|
|
1759
|
+
* Returns the new status if it escalated, null if unchanged.
|
|
1760
|
+
* Use this to emit budget warnings to the user.
|
|
1761
|
+
*/
|
|
1762
|
+
checkBudgetWarning(): BudgetStatus | null;
|
|
1763
|
+
/** Get cache efficiency metrics */
|
|
1764
|
+
getCacheMetrics(): {
|
|
1765
|
+
totalCacheReads: number;
|
|
1766
|
+
totalCacheWrites: number;
|
|
1767
|
+
cacheHitRate: number;
|
|
1768
|
+
savings: number;
|
|
1769
|
+
};
|
|
1554
1770
|
/** Get session duration in ms */
|
|
1555
1771
|
getSessionDuration(): number;
|
|
1556
1772
|
/** Reset for new session */
|
|
@@ -1643,6 +1859,16 @@ interface ExecutorResult {
|
|
|
1643
1859
|
type: 'tool_result';
|
|
1644
1860
|
}>;
|
|
1645
1861
|
}
|
|
1862
|
+
interface ProgressEvent {
|
|
1863
|
+
toolName: string;
|
|
1864
|
+
toolId: string;
|
|
1865
|
+
message: string;
|
|
1866
|
+
}
|
|
1867
|
+
/** Union type for events yielded by getRemainingResults() */
|
|
1868
|
+
type ExecutorEvent = ExecutorResult | {
|
|
1869
|
+
type: 'progress';
|
|
1870
|
+
progress: ProgressEvent;
|
|
1871
|
+
};
|
|
1646
1872
|
type ToolExecutionFn = (toolCall: {
|
|
1647
1873
|
id: string;
|
|
1648
1874
|
name: string;
|
|
@@ -1661,6 +1887,8 @@ declare class StreamingToolExecutor {
|
|
|
1661
1887
|
private bashErrorDescription;
|
|
1662
1888
|
private siblingAbortController;
|
|
1663
1889
|
private discarded;
|
|
1890
|
+
private pendingProgress;
|
|
1891
|
+
private progressAvailableResolve;
|
|
1664
1892
|
private readonly toolRegistry;
|
|
1665
1893
|
private readonly executorConfig;
|
|
1666
1894
|
private readonly toolContext?;
|
|
@@ -1675,6 +1903,8 @@ declare class StreamingToolExecutor {
|
|
|
1675
1903
|
constructor(tools: ToolRegistry, configOrContext?: ExecutorConfig | ToolExecutionContext, autoMode?: AutoModeManager, onPermissionRequest?: (operation: string, details?: string) => Promise<boolean>, executeFn?: ToolExecutionFn);
|
|
1676
1904
|
/** Discard all pending/in-progress tools */
|
|
1677
1905
|
discard(): void;
|
|
1906
|
+
/** P0.2: Emit a progress event for a running tool */
|
|
1907
|
+
onToolProgress(toolName: string, toolId: string, message: string): void;
|
|
1678
1908
|
/** Add a tool to the execution queue. Starts immediately if conditions allow. */
|
|
1679
1909
|
addTool(toolCall: {
|
|
1680
1910
|
id: string;
|
|
@@ -1683,8 +1913,10 @@ declare class StreamingToolExecutor {
|
|
|
1683
1913
|
}): void;
|
|
1684
1914
|
/** Get completed results in queue order (non-blocking) */
|
|
1685
1915
|
getCompletedResults(): Generator<ExecutorResult, void>;
|
|
1686
|
-
/**
|
|
1687
|
-
|
|
1916
|
+
/** Drain buffered progress events */
|
|
1917
|
+
drainProgress(): Generator<ProgressEvent, void>;
|
|
1918
|
+
/** Wait for all remaining tools and yield results + progress events as they arrive */
|
|
1919
|
+
getRemainingResults(): AsyncGenerator<ExecutorEvent, void>;
|
|
1688
1920
|
/** Execute a batch of tool calls and return all results */
|
|
1689
1921
|
executeTools(requests: ToolCallRequest[], context: ToolExecutionContext): Promise<ToolCallResult[]>;
|
|
1690
1922
|
/** Cancel all running tools (backward-compatible alias for discard()) */
|
|
@@ -1721,6 +1953,7 @@ interface MessageForCompaction {
|
|
|
1721
1953
|
declare class ContextCompactor {
|
|
1722
1954
|
private config;
|
|
1723
1955
|
private adapter;
|
|
1956
|
+
private consecutiveFailures;
|
|
1724
1957
|
constructor(config: CompactionConfig, adapter?: ProviderAdapter | null);
|
|
1725
1958
|
shouldCompact(messages: MessageForCompaction[]): boolean;
|
|
1726
1959
|
compact(messages: MessageForCompaction[], systemPrompt?: string): Promise<CompactionResult>;
|
|
@@ -1884,55 +2117,6 @@ declare class MCPConnectionManager {
|
|
|
1884
2117
|
disconnectAll(): Promise<void>;
|
|
1885
2118
|
}
|
|
1886
2119
|
|
|
1887
|
-
type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
1888
|
-
interface TaskDefinition {
|
|
1889
|
-
id: string;
|
|
1890
|
-
name: string;
|
|
1891
|
-
description: string;
|
|
1892
|
-
type: 'agent' | 'shell' | 'custom';
|
|
1893
|
-
status: TaskStatus;
|
|
1894
|
-
createdAt: number;
|
|
1895
|
-
startedAt?: number;
|
|
1896
|
-
completedAt?: number;
|
|
1897
|
-
error?: string;
|
|
1898
|
-
result?: string;
|
|
1899
|
-
progress?: number;
|
|
1900
|
-
}
|
|
1901
|
-
interface TaskEvents {
|
|
1902
|
-
onProgress: (taskId: string, progress: number, message?: string) => void;
|
|
1903
|
-
onComplete: (taskId: string, result: string) => void;
|
|
1904
|
-
onError: (taskId: string, error: string) => void;
|
|
1905
|
-
onStatusChange: (taskId: string, status: TaskStatus) => void;
|
|
1906
|
-
}
|
|
1907
|
-
type TaskEventName = keyof TaskEvents;
|
|
1908
|
-
type TaskEventHandler<E extends TaskEventName> = TaskEvents[E];
|
|
1909
|
-
|
|
1910
|
-
declare class TaskManager {
|
|
1911
|
-
private tasks;
|
|
1912
|
-
private listeners;
|
|
1913
|
-
private idCounter;
|
|
1914
|
-
createTask(definition: Omit<TaskDefinition, 'id' | 'status' | 'createdAt'>): string;
|
|
1915
|
-
cancelTask(id: string): void;
|
|
1916
|
-
getTask(id: string): TaskDefinition | undefined;
|
|
1917
|
-
listTasks(filter?: {
|
|
1918
|
-
status?: TaskStatus;
|
|
1919
|
-
}): TaskDefinition[];
|
|
1920
|
-
getActiveCount(): number;
|
|
1921
|
-
removeTask(id: string): void;
|
|
1922
|
-
clearCompleted(): void;
|
|
1923
|
-
on<E extends TaskEventName>(event: E, handler: TaskEventHandler<E>): void;
|
|
1924
|
-
off<E extends TaskEventName>(event: E, handler: TaskEventHandler<E>): void;
|
|
1925
|
-
/** @internal Update task status */
|
|
1926
|
-
updateStatus(id: string, status: TaskStatus): void;
|
|
1927
|
-
/** @internal Update task progress */
|
|
1928
|
-
updateProgress(id: string, progress: number, message?: string): void;
|
|
1929
|
-
/** @internal Set task result */
|
|
1930
|
-
setResult(id: string, result: string): void;
|
|
1931
|
-
/** @internal Set task error */
|
|
1932
|
-
setError(id: string, error: string): void;
|
|
1933
|
-
private emit;
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
2120
|
declare function executeAgentTask(taskId: string, manager: TaskManager, adapter: ProviderAdapter, tools: ToolRegistry, prompt: string, signal?: AbortSignal): Promise<void>;
|
|
1937
2121
|
declare function executeShellTask(taskId: string, manager: TaskManager, command: string, cwd: string, signal?: AbortSignal): Promise<void>;
|
|
1938
2122
|
|
|
@@ -2012,16 +2196,18 @@ interface InkAppProps {
|
|
|
2012
2196
|
model: string;
|
|
2013
2197
|
toolCount: number;
|
|
2014
2198
|
onSubmit: (message: string, onEvent: LoopEventHandler) => Promise<void>;
|
|
2199
|
+
/** Called when user presses Escape during active processing — should abort the current request */
|
|
2200
|
+
onCancel?: () => void;
|
|
2015
2201
|
}
|
|
2016
2202
|
declare const StatusBar: React.NamedExoticComponent<StatusBarProps>;
|
|
2017
2203
|
declare const Spinner: React.NamedExoticComponent<{
|
|
2018
2204
|
label: string;
|
|
2019
2205
|
}>;
|
|
2020
|
-
declare function InkApp({ model, toolCount, onSubmit }: InkAppProps): React.ReactElement;
|
|
2206
|
+
declare function InkApp({ model, toolCount, onSubmit, onCancel }: InkAppProps): React.ReactElement;
|
|
2021
2207
|
declare function renderInkApp(props: InkAppProps): void;
|
|
2022
2208
|
declare function formatAnsiMessage(message: ChatMessage): string;
|
|
2023
2209
|
declare function MessageList({ messages }: {
|
|
2024
2210
|
messages: ChatMessage[];
|
|
2025
2211
|
}): React.ReactElement;
|
|
2026
2212
|
|
|
2027
|
-
export { AdapterRegistry, type AgentConfig, type AgentRole, AgentTool, type AppConfig, type ChatMessage, type CommandAnalysis, type CompactionConfig, type CompactionResult, type CompletionRequest, type CompletionResult, ContextCompactor, type CostConfig, type CostEntry, CostTracker, type EnhancedMemoryConfig, type EnhancedMemoryEntry, EnhancedMemoryStore, EnterPlanModeTool, type ExecutorConfig, ExitPlanModeTool, GenericCompatAdapter, type HistoryConfig, type HistoryEntry, HistoryManager, type HookCondition, type HookContext, type HookDefinition, type HookEvent, HookExecutor, HookRegistry, type HookResult, InkApp, type InkAppProps, type JSONRPCRequest, type JSONRPCResponse, type LoopEventHandler, LspTool, MCPClient, MCPConnectionManager, type MCPPrompt, type MCPResource, type MCPServerConfig, type MCPTool, type MemoryEntry, type MemorySearchResult, MemoryStore, type Message, type MessageForCompaction, MessageList, type ModelRouterFactory, type ModelUsage, type ParsedCommand, PermissionManager, type ProviderAdapter, type ProviderConfig, QueryEngine, type QueryEngineConfig, type QueryEvent, type QueryResult, type Redirection, type RegistryFactory, type SkillDefinition, SkillRegistry, Spinner, StatusBar, type StatusBarProps, type StreamEvent, StreamingToolExecutor, type SubTask, SwarmCoordinator, type SwarmMessage, type SwarmResult, type
|
|
2213
|
+
export { AdapterRegistry, type AgentConfig, type AgentRole, AgentTool, type AppConfig, type ChatMessage, type CommandAnalysis, type CompactionConfig, type CompactionResult, type CompletionRequest, type CompletionResult, ContextCompactor, type CostConfig, type CostEntry, CostTracker, type EnhancedMemoryConfig, type EnhancedMemoryEntry, EnhancedMemoryStore, EnterPlanModeTool, type ExecutorConfig, ExitPlanModeTool, GenericCompatAdapter, type HistoryConfig, type HistoryEntry, HistoryManager, type HookCondition, type HookContext, type HookDefinition, type HookEvent, HookExecutor, HookRegistry, type HookResult, InkApp, type InkAppProps, type JSONRPCRequest, type JSONRPCResponse, type LoopEventHandler, LspTool, MCPClient, MCPConnectionManager, type MCPPrompt, type MCPResource, type MCPServerConfig, type MCPTool, type MemoryEntry, type MemorySearchResult, MemoryStore, type Message, type MessageForCompaction, MessageList, type ModelRouterFactory, type ModelUsage, type ParsedCommand, PermissionManager, type ProviderAdapter, type ProviderConfig, QueryEngine, type QueryEngineConfig, type QueryEvent, type QueryResult, type Redirection, type RegistryFactory, type SkillDefinition, SkillRegistry, Spinner, StatusBar, type StatusBarProps, type StreamEvent, StreamingToolExecutor, type SubTask, SwarmCoordinator, type SwarmMessage, type SwarmResult, type Task, type TaskCreateOptions, TaskManager, type TaskStatus, type TokenBudgetAnalysis, type ToolCallRequest, type ToolCallResult, type ToolContract, ToolRegistry, WebSearchTool, analyzeCommand, analyzeTokenBudget, createDefaultToolRegistry, estimateMessagesTokens, estimateTokens, executeAgentTask, executeShellTask, formatAnsiMessage, inspectCommand, parseCommand, renderInkApp, runAgentLoop };
|