@opencow-ai/opencow-agent-sdk 0.4.15 → 0.4.17
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/capabilities/tools/BashTool/prompt.d.ts +1 -0
- package/dist/capabilities/tools/NotebookEditTool/NotebookEditTool.d.ts +0 -8
- package/dist/cli.mjs +1101 -2057
- package/dist/client.js +56 -417
- package/dist/constants/envVars.d.ts +0 -1
- package/dist/providers/shared/model/model.d.ts +0 -9
- package/dist/sdk.js +56 -417
- package/dist/session/sessionStorage.d.ts +0 -4
- package/dist/session/settings/types.d.ts +0 -5
- package/dist/state/AppStateStore.d.ts +0 -2
- package/dist/types/hooks.d.ts +0 -2
- package/dist/types/logs.d.ts +1 -26
- package/dist/types/toolRuntime.d.ts +0 -2
- package/package.json +1 -1
- package/dist/capabilities/generatedFiles.d.ts +0 -14
- package/dist/capabilities/tools/shared/teamMemorySync/index.d.ts +0 -121
- package/dist/capabilities/tools/shared/teamMemorySync/types.d.ts +0 -132
- package/dist/capabilities/tools/shared/teamMemorySync/watcher.d.ts +0 -78
- package/dist/lib/sequential.d.ts +0 -12
- package/dist/session/attribution.d.ts +0 -40
- package/dist/session/commitAttribution.d.ts +0 -193
- package/dist/session/sessionFileAccessHooks.d.ts +0 -11
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { type UUID } from 'crypto';
|
|
2
|
-
import type { AttributionSnapshotMessage, FileAttributionState } from '../types/logs.js';
|
|
3
|
-
import { type ModelName } from '../providers/shared/model/model.js';
|
|
4
|
-
/**
|
|
5
|
-
* Get the repo root for attribution operations.
|
|
6
|
-
* Uses getCwd() which respects agent worktree overrides (AsyncLocalStorage),
|
|
7
|
-
* then resolves to git root to handle `cd subdir` case.
|
|
8
|
-
* Falls back to getOriginalCwd() if git root can't be determined.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getAttributionRepoRoot(): string;
|
|
11
|
-
type RepoClass = 'internal' | 'external' | 'none';
|
|
12
|
-
/**
|
|
13
|
-
* Synchronously return the cached repo classification for the current
|
|
14
|
-
* attribution repo root. Returns null if the async check hasn't run
|
|
15
|
-
* yet for this root.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getRepoClassCached(): RepoClass | null;
|
|
18
|
-
/**
|
|
19
|
-
* Synchronously return the cached result of isInternalModelRepo().
|
|
20
|
-
* Returns false if the check hasn't run yet (safe default: don't leak).
|
|
21
|
-
*/
|
|
22
|
-
export declare function isInternalModelRepoCached(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Check if the current repo is in the allowlist for internal model names.
|
|
25
|
-
* Memoized per attribution repo root — a single process running queries
|
|
26
|
-
* in multiple projects (SDK host) gets one classification per project.
|
|
27
|
-
*/
|
|
28
|
-
export declare const isInternalModelRepo: () => Promise<boolean>;
|
|
29
|
-
/**
|
|
30
|
-
* Sanitize a surface key to use public model names.
|
|
31
|
-
* Converts internal model variants to their public equivalents.
|
|
32
|
-
*/
|
|
33
|
-
export declare function sanitizeSurfaceKey(surfaceKey: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Sanitize a model name to its public equivalent.
|
|
36
|
-
* Maps internal variants to their public names based on model family.
|
|
37
|
-
*/
|
|
38
|
-
export declare function sanitizeModelName(shortName: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Attribution state for tracking Claude's contributions to files.
|
|
41
|
-
*/
|
|
42
|
-
export type AttributionState = {
|
|
43
|
-
fileStates: Map<string, FileAttributionState>;
|
|
44
|
-
sessionBaselines: Map<string, {
|
|
45
|
-
contentHash: string;
|
|
46
|
-
mtime: number;
|
|
47
|
-
}>;
|
|
48
|
-
surface: string;
|
|
49
|
-
startingHeadSha: string | null;
|
|
50
|
-
promptCount: number;
|
|
51
|
-
promptCountAtLastCommit: number;
|
|
52
|
-
permissionPromptCount: number;
|
|
53
|
-
permissionPromptCountAtLastCommit: number;
|
|
54
|
-
escapeCount: number;
|
|
55
|
-
escapeCountAtLastCommit: number;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Summary of Claude's contribution for a commit.
|
|
59
|
-
*/
|
|
60
|
-
export type AttributionSummary = {
|
|
61
|
-
claudePercent: number;
|
|
62
|
-
claudeChars: number;
|
|
63
|
-
humanChars: number;
|
|
64
|
-
surfaces: string[];
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Per-file attribution details for git notes.
|
|
68
|
-
*/
|
|
69
|
-
export type FileAttribution = {
|
|
70
|
-
claudeChars: number;
|
|
71
|
-
humanChars: number;
|
|
72
|
-
percent: number;
|
|
73
|
-
surface: string;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Full attribution data for git notes JSON.
|
|
77
|
-
*/
|
|
78
|
-
export type AttributionData = {
|
|
79
|
-
version: 1;
|
|
80
|
-
summary: AttributionSummary;
|
|
81
|
-
files: Record<string, FileAttribution>;
|
|
82
|
-
surfaceBreakdown: Record<string, {
|
|
83
|
-
claudeChars: number;
|
|
84
|
-
percent: number;
|
|
85
|
-
}>;
|
|
86
|
-
excludedGenerated: string[];
|
|
87
|
-
sessions: string[];
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Get the current client surface from environment.
|
|
91
|
-
*/
|
|
92
|
-
export declare function getClientSurface(): string;
|
|
93
|
-
/**
|
|
94
|
-
* Build a surface key that includes the model name.
|
|
95
|
-
* Format: "surface/model" (e.g., "cli/claude-sonnet")
|
|
96
|
-
*/
|
|
97
|
-
export declare function buildSurfaceKey(surface: string, model: ModelName): string;
|
|
98
|
-
/**
|
|
99
|
-
* Compute SHA-256 hash of content.
|
|
100
|
-
*/
|
|
101
|
-
export declare function computeContentHash(content: string): string;
|
|
102
|
-
/**
|
|
103
|
-
* Normalize file path to relative path from cwd for consistent tracking.
|
|
104
|
-
* Resolves symlinks to handle /tmp vs /private/tmp on macOS.
|
|
105
|
-
*/
|
|
106
|
-
export declare function normalizeFilePath(filePath: string): string;
|
|
107
|
-
/**
|
|
108
|
-
* Expand a relative path to absolute path.
|
|
109
|
-
*/
|
|
110
|
-
export declare function expandFilePath(filePath: string): string;
|
|
111
|
-
/**
|
|
112
|
-
* Create an empty attribution state for a new session.
|
|
113
|
-
*/
|
|
114
|
-
export declare function createEmptyAttributionState(): AttributionState;
|
|
115
|
-
/**
|
|
116
|
-
* Get a file's modification time (mtimeMs), falling back to Date.now() if
|
|
117
|
-
* the file doesn't exist. This is async so it can be precomputed before
|
|
118
|
-
* entering a sync setAppState callback.
|
|
119
|
-
*/
|
|
120
|
-
export declare function getFileMtime(filePath: string): Promise<number>;
|
|
121
|
-
/**
|
|
122
|
-
* Track a file modification by Claude.
|
|
123
|
-
* Called after Edit/Write tool completes.
|
|
124
|
-
*/
|
|
125
|
-
export declare function trackFileModification(state: AttributionState, filePath: string, oldContent: string, newContent: string, _userModified: boolean, mtime?: number): AttributionState;
|
|
126
|
-
/**
|
|
127
|
-
* Track a file creation by Claude (e.g., via bash command).
|
|
128
|
-
* Used when Claude creates a new file through a non-tracked mechanism.
|
|
129
|
-
*/
|
|
130
|
-
export declare function trackFileCreation(state: AttributionState, filePath: string, content: string, mtime?: number): AttributionState;
|
|
131
|
-
/**
|
|
132
|
-
* Track a file deletion by Claude (e.g., via bash rm command).
|
|
133
|
-
* Used when Claude deletes a file through a non-tracked mechanism.
|
|
134
|
-
*/
|
|
135
|
-
export declare function trackFileDeletion(state: AttributionState, filePath: string, oldContent: string): AttributionState;
|
|
136
|
-
/**
|
|
137
|
-
* Track multiple file changes in bulk, mutating a single Map copy.
|
|
138
|
-
* This avoids the O(n²) cost of copying the Map per file when processing
|
|
139
|
-
* large git diffs (e.g., jj operations that touch hundreds of thousands of files).
|
|
140
|
-
*/
|
|
141
|
-
export declare function trackBulkFileChanges(state: AttributionState, changes: ReadonlyArray<{
|
|
142
|
-
path: string;
|
|
143
|
-
type: 'modified' | 'created' | 'deleted';
|
|
144
|
-
oldContent: string;
|
|
145
|
-
newContent: string;
|
|
146
|
-
mtime?: number;
|
|
147
|
-
}>): AttributionState;
|
|
148
|
-
/**
|
|
149
|
-
* Calculate final attribution for staged files.
|
|
150
|
-
* Compares session baseline to committed state.
|
|
151
|
-
*/
|
|
152
|
-
export declare function calculateCommitAttribution(states: AttributionState[], stagedFiles: string[]): Promise<AttributionData>;
|
|
153
|
-
/**
|
|
154
|
-
* Get the size of changes for a file from git diff.
|
|
155
|
-
* Returns the number of characters added/removed (absolute difference).
|
|
156
|
-
* For new files, returns the total file size.
|
|
157
|
-
* For deleted files, returns the size of the deleted content.
|
|
158
|
-
*/
|
|
159
|
-
export declare function getGitDiffSize(filePath: string): Promise<number>;
|
|
160
|
-
/**
|
|
161
|
-
* Check if a file was deleted in the staged changes.
|
|
162
|
-
*/
|
|
163
|
-
export declare function isFileDeleted(filePath: string): Promise<boolean>;
|
|
164
|
-
/**
|
|
165
|
-
* Get staged files from git.
|
|
166
|
-
*/
|
|
167
|
-
export declare function getStagedFiles(): Promise<string[]>;
|
|
168
|
-
/**
|
|
169
|
-
* Check if we're in a transient git state (rebase, merge, cherry-pick).
|
|
170
|
-
*/
|
|
171
|
-
export declare function isGitTransientState(): Promise<boolean>;
|
|
172
|
-
/**
|
|
173
|
-
* Convert attribution state to snapshot message for persistence.
|
|
174
|
-
*/
|
|
175
|
-
export declare function stateToSnapshotMessage(state: AttributionState, messageId: UUID): AttributionSnapshotMessage;
|
|
176
|
-
/**
|
|
177
|
-
* Restore attribution state from snapshot messages.
|
|
178
|
-
*/
|
|
179
|
-
export declare function restoreAttributionStateFromSnapshots(snapshots: AttributionSnapshotMessage[]): AttributionState;
|
|
180
|
-
/**
|
|
181
|
-
* Restore attribution state from log snapshots on session resume.
|
|
182
|
-
*/
|
|
183
|
-
export declare function attributionRestoreStateFromLog(attributionSnapshots: AttributionSnapshotMessage[], onUpdateState: (newState: AttributionState) => void): void;
|
|
184
|
-
/**
|
|
185
|
-
* Increment promptCount and save an attribution snapshot.
|
|
186
|
-
* Used to persist the prompt count across compaction.
|
|
187
|
-
*
|
|
188
|
-
* @param attribution - Current attribution state
|
|
189
|
-
* @param saveSnapshot - Function to save the snapshot (allows async handling by caller)
|
|
190
|
-
* @returns New attribution state with incremented promptCount
|
|
191
|
-
*/
|
|
192
|
-
export declare function incrementPromptCount(attribution: AttributionState, saveSnapshot: (snapshot: AttributionSnapshotMessage) => void): AttributionState;
|
|
193
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a tool use constitutes a memory file access.
|
|
3
|
-
* Detects session memory (via Read/Grep/Glob) and memdir access (via Read/Edit/Write).
|
|
4
|
-
* Uses the same conditions as the PostToolUse session file access hooks.
|
|
5
|
-
*/
|
|
6
|
-
export declare function isMemoryFileAccess(toolName: string, toolInput: unknown): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Register session file access tracking hooks.
|
|
9
|
-
* Called during CLI initialization.
|
|
10
|
-
*/
|
|
11
|
-
export declare function registerSessionFileAccessHooks(): void;
|