@opencow-ai/opencow-agent-sdk 0.4.16 → 0.4.18

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.
Files changed (38) hide show
  1. package/README.md +6 -0
  2. package/dist/Tool.d.ts +5 -11
  3. package/dist/capabilities/mcp/utils.d.ts +6 -6
  4. package/dist/capabilities/shell/posixShellDetection.d.ts +1 -0
  5. package/dist/capabilities/shell/powershellDetection.d.ts +1 -10
  6. package/dist/capabilities/shell/shellCapabilities.d.ts +33 -0
  7. package/dist/capabilities/shell/shellProvider.d.ts +0 -1
  8. package/dist/capabilities/shell/shellToolUtils.d.ts +0 -10
  9. package/dist/capabilities/tools/BashTool/prompt.d.ts +1 -0
  10. package/dist/capabilities/tools/NotebookEditTool/NotebookEditTool.d.ts +0 -8
  11. package/dist/cli.mjs +174762 -175646
  12. package/dist/client.js +4518 -4772
  13. package/dist/constants/envVars.d.ts +0 -2
  14. package/dist/constants/prompts.d.ts +6 -4
  15. package/dist/entrypoints/sdk/runtimeTypes.d.ts +9 -0
  16. package/dist/lib/frontmatterParser.d.ts +4 -4
  17. package/dist/lib/windowsPaths.d.ts +12 -10
  18. package/dist/providers/shared/model/model.d.ts +0 -9
  19. package/dist/sdk.js +4518 -4772
  20. package/dist/session/collapseReadSearch.d.ts +2 -1
  21. package/dist/session/promptShellExecution.d.ts +3 -5
  22. package/dist/session/sessionStorage.d.ts +0 -4
  23. package/dist/session/settings/types.d.ts +0 -9
  24. package/dist/state/AppStateStore.d.ts +3 -4
  25. package/dist/tasks/LocalAgentTask/LocalAgentTask.d.ts +3 -3
  26. package/dist/tools.d.ts +6 -7
  27. package/dist/types/hooks.d.ts +0 -2
  28. package/dist/types/logs.d.ts +1 -26
  29. package/dist/types/toolRuntime.d.ts +0 -2
  30. package/package.json +1 -1
  31. package/dist/capabilities/generatedFiles.d.ts +0 -14
  32. package/dist/capabilities/tools/shared/teamMemorySync/index.d.ts +0 -121
  33. package/dist/capabilities/tools/shared/teamMemorySync/types.d.ts +0 -132
  34. package/dist/capabilities/tools/shared/teamMemorySync/watcher.d.ts +0 -78
  35. package/dist/lib/sequential.d.ts +0 -12
  36. package/dist/session/attribution.d.ts +0 -40
  37. package/dist/session/commitAttribution.d.ts +0 -193
  38. package/dist/session/sessionFileAccessHooks.d.ts +0 -11
@@ -1,40 +0,0 @@
1
- import type { AppState } from '../state/AppStateStore.js';
2
- export type AttributionTexts = {
3
- commit: string;
4
- pr: string;
5
- };
6
- /**
7
- * Returns attribution text for commits and PRs based on user settings.
8
- * Handles:
9
- * - Dynamic model name via getPublicModelName()
10
- * - Custom attribution settings (settings.attribution.commit/pr)
11
- * - Backward compatibility with deprecated includeCoAuthoredBy setting
12
- * - Remote mode: returns session URL for attribution
13
- */
14
- export declare function getAttributionTexts(): AttributionTexts;
15
- /**
16
- * Count user messages with visible text content in a list of non-sidechain messages.
17
- * Excludes tool_result blocks, terminal output, and empty messages.
18
- *
19
- * Callers should pass messages already filtered to exclude sidechain messages.
20
- */
21
- export declare function countUserPromptsInMessages(messages: ReadonlyArray<{
22
- type: string;
23
- message?: {
24
- content?: unknown;
25
- };
26
- }>): number;
27
- /**
28
- * Get enhanced PR attribution text with Claude contribution stats.
29
- *
30
- * Format: "šŸ¤– Generated with Claude Code (93% 3-shotted by claude-opus-4-5)"
31
- *
32
- * Rules:
33
- * - Shows Claude contribution percentage from commit attribution
34
- * - Shows N-shotted where N is the prompt count (1-shotted, 2-shotted, etc.)
35
- * - Shows short model name (e.g., claude-opus-4-5)
36
- * - Returns default attribution if stats can't be computed
37
- *
38
- * @param getAppState Function to get the current AppState (from command context)
39
- */
40
- export declare function getEnhancedPRAttribution(getAppState: () => AppState): Promise<string>;
@@ -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;