@cuylabs/agent-core 0.3.0 → 0.5.0
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 +216 -41
- package/dist/builder-RcTZuYnO.d.ts +34 -0
- package/dist/capabilities/index.d.ts +97 -0
- package/dist/capabilities/index.js +46 -0
- package/dist/chunk-6TDTQJ4P.js +116 -0
- package/dist/chunk-7MUFEN4K.js +559 -0
- package/dist/chunk-BDBZ3SLK.js +745 -0
- package/dist/chunk-DWYX7ASF.js +26 -0
- package/dist/chunk-FG4MD5MU.js +54 -0
- package/dist/chunk-IMGQOTU2.js +2019 -0
- package/dist/chunk-IVUJDISU.js +556 -0
- package/dist/chunk-LRHOS4ZN.js +584 -0
- package/dist/chunk-OTUGSCED.js +691 -0
- package/dist/chunk-P6YF7USR.js +182 -0
- package/dist/chunk-QAQADS4X.js +258 -0
- package/dist/chunk-QWFMX226.js +879 -0
- package/dist/{chunk-6VKLWNRE.js → chunk-SDSBEQXG.js} +1 -132
- package/dist/chunk-VBWWUHWI.js +724 -0
- package/dist/chunk-VEKUXUVF.js +41 -0
- package/dist/chunk-X635CM2F.js +305 -0
- package/dist/chunk-YUUJK53A.js +91 -0
- package/dist/chunk-ZXAKHMWH.js +283 -0
- package/dist/config-D2xeGEHK.d.ts +52 -0
- package/dist/context/index.d.ts +259 -0
- package/dist/context/index.js +26 -0
- package/dist/identifiers-BLUxFqV_.d.ts +12 -0
- package/dist/index-p0kOsVsE.d.ts +1067 -0
- package/dist/index-tmhaADz5.d.ts +198 -0
- package/dist/index.d.ts +185 -4316
- package/dist/index.js +1238 -5368
- package/dist/mcp/index.d.ts +26 -0
- package/dist/mcp/index.js +14 -0
- package/dist/messages-BYWGn8TY.d.ts +110 -0
- package/dist/middleware/index.d.ts +7 -0
- package/dist/middleware/index.js +12 -0
- package/dist/models/index.d.ts +33 -0
- package/dist/models/index.js +12 -0
- package/dist/network-D76DS5ot.d.ts +5 -0
- package/dist/prompt/index.d.ts +224 -0
- package/dist/prompt/index.js +45 -0
- package/dist/reasoning/index.d.ts +71 -0
- package/dist/reasoning/index.js +47 -0
- package/dist/registry-CuRWWtcT.d.ts +164 -0
- package/dist/resolver-DOfZ-xuk.d.ts +254 -0
- package/dist/runner-C7aMP_x3.d.ts +596 -0
- package/dist/runtime/index.d.ts +357 -0
- package/dist/runtime/index.js +64 -0
- package/dist/session-manager-Uawm2Le7.d.ts +274 -0
- package/dist/skill/index.d.ts +103 -0
- package/dist/skill/index.js +39 -0
- package/dist/storage/index.d.ts +167 -0
- package/dist/storage/index.js +50 -0
- package/dist/sub-agent/index.d.ts +14 -0
- package/dist/sub-agent/index.js +15 -0
- package/dist/tool/index.d.ts +173 -1
- package/dist/tool/index.js +12 -3
- package/dist/tool-DYp6-cC3.d.ts +239 -0
- package/dist/tool-pFAnJc5Y.d.ts +419 -0
- package/dist/tracker-DClqYqTj.d.ts +96 -0
- package/dist/tracking/index.d.ts +109 -0
- package/dist/tracking/index.js +20 -0
- package/dist/types-CQaXbRsS.d.ts +47 -0
- package/dist/types-MM1JoX5T.d.ts +810 -0
- package/dist/types-VQgymC1N.d.ts +156 -0
- package/package.json +89 -5
- package/dist/index-QR704uRr.d.ts +0 -472
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn-tracker contracts for @cuylabs/agent-core.
|
|
3
|
+
*/
|
|
4
|
+
/** Configuration for turn tracking. */
|
|
5
|
+
interface TurnTrackerConfig {
|
|
6
|
+
/** Working directory (absolute path) - all paths resolve relative to this */
|
|
7
|
+
cwd: string;
|
|
8
|
+
/** Whether to try git-aware diffs when available. Default: auto-detect */
|
|
9
|
+
useGit?: boolean;
|
|
10
|
+
/** Maximum files to track per turn. Default: 100 */
|
|
11
|
+
maxTrackedFiles?: number;
|
|
12
|
+
}
|
|
13
|
+
/** File baseline captured before modification. */
|
|
14
|
+
interface FileBaseline {
|
|
15
|
+
/** Absolute path */
|
|
16
|
+
path: string;
|
|
17
|
+
/** Content before modification (null if file did not exist) */
|
|
18
|
+
content: string | null;
|
|
19
|
+
/** File mode (permissions) */
|
|
20
|
+
mode: number | null;
|
|
21
|
+
/** Hash of original content for quick comparison */
|
|
22
|
+
hash: string | null;
|
|
23
|
+
/** When baseline was captured */
|
|
24
|
+
capturedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
/** Single file change within a turn. */
|
|
27
|
+
interface TurnFileChange {
|
|
28
|
+
/** Relative path (from cwd) */
|
|
29
|
+
path: string;
|
|
30
|
+
/** Type of change */
|
|
31
|
+
type: "created" | "modified" | "deleted" | "unchanged";
|
|
32
|
+
/** Lines added */
|
|
33
|
+
additions: number;
|
|
34
|
+
/** Lines removed */
|
|
35
|
+
deletions: number;
|
|
36
|
+
/** Unified diff for this file */
|
|
37
|
+
diff?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Summary of a completed turn. */
|
|
40
|
+
interface TurnSummary {
|
|
41
|
+
/** Turn identifier */
|
|
42
|
+
turnId: string;
|
|
43
|
+
/** Files changed */
|
|
44
|
+
files: TurnFileChange[];
|
|
45
|
+
/** Total files tracked */
|
|
46
|
+
totalTracked: number;
|
|
47
|
+
/** Total additions across all files */
|
|
48
|
+
additions: number;
|
|
49
|
+
/** Total deletions across all files */
|
|
50
|
+
deletions: number;
|
|
51
|
+
/** Combined unified diff for all changes */
|
|
52
|
+
diff: string | null;
|
|
53
|
+
/** Turn duration in ms */
|
|
54
|
+
duration: number;
|
|
55
|
+
}
|
|
56
|
+
/** Result of undo operation. */
|
|
57
|
+
interface UndoResult {
|
|
58
|
+
/** Files restored */
|
|
59
|
+
restored: string[];
|
|
60
|
+
/** Files that could not be restored */
|
|
61
|
+
failed: Array<{
|
|
62
|
+
path: string;
|
|
63
|
+
reason: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Turn Change Tracker - Per-turn file modification tracking.
|
|
69
|
+
*
|
|
70
|
+
* Tracks file changes within a single agent turn for undo/diff capabilities.
|
|
71
|
+
* Unlike checkpoints (session-level snapshots), this only captures files that
|
|
72
|
+
* were actually touched during the active turn.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
declare class TurnChangeTracker {
|
|
76
|
+
private config;
|
|
77
|
+
private currentTurn;
|
|
78
|
+
private gitDetected;
|
|
79
|
+
constructor(config: TurnTrackerConfig);
|
|
80
|
+
startTurn(turnId: string): void;
|
|
81
|
+
endTurn(): Promise<TurnSummary>;
|
|
82
|
+
isInTurn(): boolean;
|
|
83
|
+
getCurrentTurnId(): string | null;
|
|
84
|
+
beforeWrite(filePath: string): Promise<boolean>;
|
|
85
|
+
getTrackedFiles(): string[];
|
|
86
|
+
isTracking(filePath: string): boolean;
|
|
87
|
+
getDiff(): Promise<string | null>;
|
|
88
|
+
getFileDiff(filePath: string): Promise<string | null>;
|
|
89
|
+
undoTurn(): Promise<UndoResult>;
|
|
90
|
+
undoFiles(filePaths: string[]): Promise<UndoResult>;
|
|
91
|
+
private computeFileChange;
|
|
92
|
+
private isInGitRepo;
|
|
93
|
+
}
|
|
94
|
+
declare function createTurnTracker(config: TurnTrackerConfig): TurnChangeTracker;
|
|
95
|
+
|
|
96
|
+
export { type FileBaseline as F, TurnChangeTracker as T, type UndoResult as U, type TurnFileChange as a, type TurnSummary as b, type TurnTrackerConfig as c, createTurnTracker as d };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { T as TurnChangeTracker } from '../tracker-DClqYqTj.js';
|
|
2
|
+
export { F as FileBaseline, a as TurnFileChange, b as TurnSummary, c as TurnTrackerConfig, U as UndoResult, d as createTurnTracker } from '../tracker-DClqYqTj.js';
|
|
3
|
+
import { F as FileOperationMeta } from '../tool-DYp6-cC3.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checkpoint system contracts for @cuylabs/agent-core.
|
|
7
|
+
*/
|
|
8
|
+
/** Configuration for creating a checkpoint manager. */
|
|
9
|
+
interface CheckpointConfig {
|
|
10
|
+
/** Working directory to track (absolute path) */
|
|
11
|
+
workDir: string;
|
|
12
|
+
/** Optional custom storage directory */
|
|
13
|
+
storageDir?: string;
|
|
14
|
+
/** Whether to track file contents (enables restore). Default: true */
|
|
15
|
+
trackContent?: boolean;
|
|
16
|
+
/** Patterns to exclude from tracking (gitignore format) */
|
|
17
|
+
exclude?: string[];
|
|
18
|
+
/** Maximum number of checkpoints to retain. Default: 100 */
|
|
19
|
+
maxCheckpoints?: number;
|
|
20
|
+
}
|
|
21
|
+
/** A saved checkpoint representing a point-in-time state. */
|
|
22
|
+
interface Checkpoint {
|
|
23
|
+
/** Unique checkpoint identifier (git tree hash) */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Human-readable label */
|
|
26
|
+
label: string;
|
|
27
|
+
/** When the checkpoint was created */
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
/** Optional metadata */
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** File change information between checkpoints. */
|
|
33
|
+
interface FileChange {
|
|
34
|
+
/** Relative file path */
|
|
35
|
+
path: string;
|
|
36
|
+
/** Type of change */
|
|
37
|
+
type: "added" | "modified" | "deleted";
|
|
38
|
+
/** Lines added (for text files) */
|
|
39
|
+
additions?: number;
|
|
40
|
+
/** Lines removed (for text files) */
|
|
41
|
+
deletions?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Changes detected between a checkpoint and current state. */
|
|
44
|
+
interface ChangeSet {
|
|
45
|
+
/** Checkpoint being compared from */
|
|
46
|
+
fromCheckpoint: string;
|
|
47
|
+
/** List of changed files */
|
|
48
|
+
files: FileChange[];
|
|
49
|
+
/** Unified diff output */
|
|
50
|
+
diff: string;
|
|
51
|
+
}
|
|
52
|
+
/** Checkpoint manager interface. */
|
|
53
|
+
interface CheckpointManager {
|
|
54
|
+
/** Save current state as a checkpoint */
|
|
55
|
+
save(label?: string, metadata?: Record<string, unknown>): Promise<Checkpoint>;
|
|
56
|
+
/** Restore all files to a checkpoint state */
|
|
57
|
+
restore(checkpointId: string): Promise<void>;
|
|
58
|
+
/** Get changes since a checkpoint */
|
|
59
|
+
changes(checkpointId: string): Promise<ChangeSet>;
|
|
60
|
+
/** Undo changes to specific files (restore them from checkpoint) */
|
|
61
|
+
undoFiles(checkpointId: string, files: string[]): Promise<void>;
|
|
62
|
+
/** List all checkpoints (newest first) */
|
|
63
|
+
list(): Promise<Checkpoint[]>;
|
|
64
|
+
/** Delete a specific checkpoint */
|
|
65
|
+
remove(checkpointId: string): Promise<void>;
|
|
66
|
+
/** Prune old checkpoints beyond maxCheckpoints limit */
|
|
67
|
+
prune(): Promise<number>;
|
|
68
|
+
/** Get the latest checkpoint */
|
|
69
|
+
latest(): Promise<Checkpoint | null>;
|
|
70
|
+
/** Get file content at a specific checkpoint */
|
|
71
|
+
getFileAt(checkpointId: string, filePath: string): Promise<string | null>;
|
|
72
|
+
/** Check if manager is initialized */
|
|
73
|
+
isInitialized(): boolean;
|
|
74
|
+
/** Close and cleanup resources */
|
|
75
|
+
close(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Creates a checkpoint manager for tracking file state changes.
|
|
80
|
+
*/
|
|
81
|
+
declare function createCheckpointManager(config: CheckpointConfig): Promise<CheckpointManager>;
|
|
82
|
+
/**
|
|
83
|
+
* Clear all checkpoint data for a working directory.
|
|
84
|
+
*/
|
|
85
|
+
declare function clearCheckpoints(workDir: string): Promise<void>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Extended tool metadata with file operation info.
|
|
89
|
+
*/
|
|
90
|
+
interface TrackedToolMetadata {
|
|
91
|
+
/** File operation metadata for auto-tracking */
|
|
92
|
+
fileOps?: FileOperationMeta;
|
|
93
|
+
/** Other metadata */
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Extract file paths from tool arguments based on metadata.
|
|
98
|
+
*/
|
|
99
|
+
declare function extractFilePathsFromArgs(args: Record<string, unknown>, meta: FileOperationMeta): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Check whether a tool operation should trigger baseline capture.
|
|
102
|
+
*/
|
|
103
|
+
declare function shouldCaptureBaseline(meta: FileOperationMeta): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Wrap a tool execute function with automatic file tracking.
|
|
106
|
+
*/
|
|
107
|
+
declare function withFileTracking<T extends (...args: unknown[]) => Promise<unknown>>(tracker: TurnChangeTracker, meta: FileOperationMeta, execute: T): T;
|
|
108
|
+
|
|
109
|
+
export { type ChangeSet, type Checkpoint, type CheckpointConfig, type CheckpointManager, type FileChange, type TrackedToolMetadata, TurnChangeTracker, clearCheckpoints, createCheckpointManager, extractFilePathsFromArgs, shouldCaptureBaseline, withFileTracking };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TurnChangeTracker,
|
|
3
|
+
clearCheckpoints,
|
|
4
|
+
createCheckpointManager,
|
|
5
|
+
createTurnTracker
|
|
6
|
+
} from "../chunk-VBWWUHWI.js";
|
|
7
|
+
import {
|
|
8
|
+
extractFilePathsFromArgs,
|
|
9
|
+
shouldCaptureBaseline,
|
|
10
|
+
withFileTracking
|
|
11
|
+
} from "../chunk-VEKUXUVF.js";
|
|
12
|
+
export {
|
|
13
|
+
TurnChangeTracker,
|
|
14
|
+
clearCheckpoints,
|
|
15
|
+
createCheckpointManager,
|
|
16
|
+
createTurnTracker,
|
|
17
|
+
extractFilePathsFromArgs,
|
|
18
|
+
shouldCaptureBaseline,
|
|
19
|
+
withFileTracking
|
|
20
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning Types & Constants
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions, level constants, and small helpers
|
|
5
|
+
* used across the reasoning subsystem.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Standard reasoning / thinking levels.
|
|
9
|
+
*
|
|
10
|
+
* | Level | Description |
|
|
11
|
+
* |------------|------------------------------------|
|
|
12
|
+
* | `"off"` | No reasoning (fastest) |
|
|
13
|
+
* | `"minimal"`| Very light reasoning |
|
|
14
|
+
* | `"low"` | Light reasoning |
|
|
15
|
+
* | `"medium"` | Balanced reasoning |
|
|
16
|
+
* | `"high"` | Deep reasoning |
|
|
17
|
+
* | `"xhigh"` | Maximum reasoning (where supported)|
|
|
18
|
+
*/
|
|
19
|
+
type ReasoningLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
20
|
+
/**
|
|
21
|
+
* Provider-specific reasoning configuration returned by
|
|
22
|
+
* {@link getReasoningConfig} / {@link getReasoningConfigSync}.
|
|
23
|
+
*/
|
|
24
|
+
interface ReasoningConfig {
|
|
25
|
+
/** Whether the model supports reasoning at all */
|
|
26
|
+
supportsReasoning: boolean;
|
|
27
|
+
/** Reasoning levels available for this model */
|
|
28
|
+
availableLevels: ReasoningLevel[];
|
|
29
|
+
/** Build provider options for a given level */
|
|
30
|
+
getProviderOptions: (level: ReasoningLevel) => Record<string, unknown> | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Standard four-level set used by most providers. */
|
|
33
|
+
declare const STANDARD_LEVELS: ReasoningLevel[];
|
|
34
|
+
/** Extended set for advanced models (e.g. o3, o4, GPT-5). */
|
|
35
|
+
declare const EXTENDED_LEVELS: ReasoningLevel[];
|
|
36
|
+
/** Fixed set for models whose reasoning level is not adjustable. */
|
|
37
|
+
declare const FIXED_LEVELS: ReasoningLevel[];
|
|
38
|
+
/**
|
|
39
|
+
* Check whether reasoning summaries should be included in responses.
|
|
40
|
+
*
|
|
41
|
+
* Controlled by the `CODE_AGENT_DISABLE_REASONING_SUMMARY` environment
|
|
42
|
+
* variable. Summaries require a verified OpenAI organisation — set the
|
|
43
|
+
* env var to `"true"` to disable them.
|
|
44
|
+
*/
|
|
45
|
+
declare function shouldIncludeReasoningSummary(): boolean;
|
|
46
|
+
|
|
47
|
+
export { EXTENDED_LEVELS as E, FIXED_LEVELS as F, type ReasoningLevel as R, STANDARD_LEVELS as S, type ReasoningConfig as a, shouldIncludeReasoningSummary as s };
|