instar 1.3.1350 → 1.3.1351
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/core/ClaudeBinaryRetainer.d.ts +186 -0
- package/dist/core/ClaudeBinaryRetainer.d.ts.map +1 -0
- package/dist/core/ClaudeBinaryRetainer.js +585 -0
- package/dist/core/ClaudeBinaryRetainer.js.map +1 -0
- package/dist/core/Config.d.ts.map +1 -1
- package/dist/core/Config.js +5 -0
- package/dist/core/Config.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +22 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SessionManager.d.ts +26 -0
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +61 -5
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/core/WriteDomainRegistry.d.ts.map +1 -1
- package/dist/core/WriteDomainRegistry.js +20 -0
- package/dist/core/WriteDomainRegistry.js.map +1 -1
- package/dist/core/types.d.ts +14 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/data/standards-guard-index.json +1 -1
- package/dist/data/standards-guard-index.meta.json +2 -2
- package/dist/data/standards-registry.meta.json +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +1 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +33 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +64 -64
- package/src/data/standards-guard-index.json +1 -1
- package/src/data/standards-guard-index.meta.json +2 -2
- package/src/data/standards-registry.meta.json +1 -1
- package/src/scaffold/templates.ts +1 -0
- package/upgrades/1.3.1351.md +28 -0
- package/upgrades/side-effects/retained-claude-executable.md +116 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export interface RetainedClaudeBinaryConfig {
|
|
2
|
+
/** Off switch. Absent = ON (the leak is the default-on failure). */
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
/** Directory holding `<version>/claude`. Default: `<projectDir>/.instar/state/claude-bin`. */
|
|
5
|
+
dir?: string;
|
|
6
|
+
/**
|
|
7
|
+
* A non-current version directory is a prune candidate only once it has
|
|
8
|
+
* not been used to launch anything for this long (default 6 h). This covers
|
|
9
|
+
* the window between "resolve picked a path" and "the process exec'd it".
|
|
10
|
+
*/
|
|
11
|
+
pruneGraceMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_PRUNE_GRACE_MS: number;
|
|
14
|
+
export declare const RETAINED_BINARY_NAME = "claude";
|
|
15
|
+
export declare const LAST_USED_MARKER = ".last-used";
|
|
16
|
+
export declare const SOURCE_MANIFEST = "source.json";
|
|
17
|
+
export type RetainFallbackReason = 'disabled' | 'source-missing' | 'source-unreadable' | 'not-a-file' | 'script-not-retained' | 'not-claude-binary' | 'retained-mismatch' | 'copy-failed';
|
|
18
|
+
export interface RetainResolution {
|
|
19
|
+
/** The path to LAUNCH. */
|
|
20
|
+
path: string;
|
|
21
|
+
source: 'retained' | 'original';
|
|
22
|
+
/** Version string when it could be read; null when a fingerprint key was used. */
|
|
23
|
+
version: string | null;
|
|
24
|
+
/** The version-directory key (`2.1.299`, `2.1.299-247931696`, `fp-…`). */
|
|
25
|
+
key: string | null;
|
|
26
|
+
/** The path as configured (what we were asked to launch). */
|
|
27
|
+
sourcePath: string;
|
|
28
|
+
/** The real file the configured path points at right now. */
|
|
29
|
+
sourceRealPath: string | null;
|
|
30
|
+
/** How the version was read. */
|
|
31
|
+
versionVia: 'package-json' | 'version-flag' | 'fingerprint' | null;
|
|
32
|
+
/** True when THIS call made the copy (a new version landed). */
|
|
33
|
+
copied: boolean;
|
|
34
|
+
reason?: RetainFallbackReason;
|
|
35
|
+
detail?: string;
|
|
36
|
+
at: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RetainedVersionEntry {
|
|
39
|
+
key: string;
|
|
40
|
+
path: string;
|
|
41
|
+
version: string | null;
|
|
42
|
+
sizeBytes: number | null;
|
|
43
|
+
copiedAt: string | null;
|
|
44
|
+
lastUsedAt: string | null;
|
|
45
|
+
current: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface PruneResult {
|
|
48
|
+
at: string;
|
|
49
|
+
checked: number;
|
|
50
|
+
removed: string[];
|
|
51
|
+
keptCurrent: string[];
|
|
52
|
+
keptInUse: string[];
|
|
53
|
+
keptRecent: string[];
|
|
54
|
+
keptUnknown: string[];
|
|
55
|
+
errors: string[];
|
|
56
|
+
skipped?: 'no-current-key' | 'disabled' | 'dir-missing';
|
|
57
|
+
}
|
|
58
|
+
export interface RetainerStatus {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
dir: string;
|
|
61
|
+
pruneGraceMs: number;
|
|
62
|
+
current: {
|
|
63
|
+
key: string;
|
|
64
|
+
version: string | null;
|
|
65
|
+
path: string;
|
|
66
|
+
} | null;
|
|
67
|
+
lastResolution: RetainResolution | null;
|
|
68
|
+
lastError: {
|
|
69
|
+
at: string;
|
|
70
|
+
message: string;
|
|
71
|
+
} | null;
|
|
72
|
+
counters: {
|
|
73
|
+
resolutions: number;
|
|
74
|
+
retained: number;
|
|
75
|
+
copies: number;
|
|
76
|
+
fallbacks: number;
|
|
77
|
+
};
|
|
78
|
+
retained: RetainedVersionEntry[];
|
|
79
|
+
lastPrune: PruneResult | null;
|
|
80
|
+
}
|
|
81
|
+
export interface ClaudeBinaryRetainerOptions {
|
|
82
|
+
dir: string;
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
pruneGraceMs?: number;
|
|
85
|
+
/** Test seam: count of live processes mapping `file` (null = cannot tell). */
|
|
86
|
+
liveMappers?: (file: string) => Promise<number | null>;
|
|
87
|
+
/** Test seam: run `<bin> --version` and return stdout. */
|
|
88
|
+
versionProbe?: (bin: string) => string;
|
|
89
|
+
/** Test seam: the copy primitive. */
|
|
90
|
+
copyFile?: (src: string, dst: string) => void;
|
|
91
|
+
now?: () => number;
|
|
92
|
+
log?: {
|
|
93
|
+
warn: (msg: string) => void;
|
|
94
|
+
error: (msg: string) => void;
|
|
95
|
+
info: (msg: string) => void;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Is the retainer ON for this process? Production default is ON (absent =
|
|
100
|
+
* on — the leak is the default-on failure). Under a test runner (VITEST set)
|
|
101
|
+
* the default is OFF: dozens of SessionManager tests pin the launch argv
|
|
102
|
+
* byte-for-byte against a configured claude path that happens to EXIST on a
|
|
103
|
+
* developer's Mac and not on CI, so a host-dependent default would make the
|
|
104
|
+
* same test pass on one machine and fail on another. An EXPLICIT
|
|
105
|
+
* `enabled: true` always wins (the retainer's own tests set it), and an
|
|
106
|
+
* explicit `false` always wins.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolveRetainerEnabled(configured: boolean | undefined, env?: NodeJS.ProcessEnv): boolean;
|
|
109
|
+
export declare function sanitizeVersionKey(version: string | null | undefined): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Read the Claude Code version for a resolved real executable path.
|
|
112
|
+
* 1. `../package.json` of the bin dir (the npm layout:
|
|
113
|
+
* `…/claude-code/bin/claude.exe` → `…/claude-code/package.json`), or a
|
|
114
|
+
* sibling `package.json`.
|
|
115
|
+
* 2. `<bin> --version` (the native installer lays the binary down as
|
|
116
|
+
* `~/.local/share/claude/versions/<ver>` with no package.json).
|
|
117
|
+
*/
|
|
118
|
+
export declare function readClaudeVersion(realPath: string, versionProbe?: (bin: string) => string): {
|
|
119
|
+
version: string | null;
|
|
120
|
+
via: 'package-json' | 'version-flag' | null;
|
|
121
|
+
};
|
|
122
|
+
/** Resolve a bare command name through PATH; absolute/relative paths pass through. */
|
|
123
|
+
export declare function locateExecutable(configured: string, env?: NodeJS.ProcessEnv): string | null;
|
|
124
|
+
/**
|
|
125
|
+
* Only a path that is plainly a Claude Code install is retained: the file is
|
|
126
|
+
* named `claude` / `claude.exe`, or a path component is the npm package dir
|
|
127
|
+
* (`claude-code`, `@anthropic-ai`), the native-installer dir (`claude`), or
|
|
128
|
+
* `.claude`. Component-exact so an unrelated directory whose NAME merely
|
|
129
|
+
* contains "claude" (a tmp dir, a project) does not qualify.
|
|
130
|
+
*/
|
|
131
|
+
export declare function looksLikeClaudeInstall(realPath: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Count live processes mapping `file`. Linux: scan `/proc/*\/exe` (no
|
|
134
|
+
* subprocess). Elsewhere: `lsof -t -- <file>` (exit 1 + empty output = none).
|
|
135
|
+
* Returns null whenever the answer is not trustworthy — the caller KEEPS.
|
|
136
|
+
*/
|
|
137
|
+
export declare function defaultLiveMappers(file: string): Promise<number | null>;
|
|
138
|
+
export declare class ClaudeBinaryRetainer {
|
|
139
|
+
readonly dir: string;
|
|
140
|
+
readonly enabled: boolean;
|
|
141
|
+
readonly pruneGraceMs: number;
|
|
142
|
+
private readonly liveMappers;
|
|
143
|
+
private readonly versionProbe;
|
|
144
|
+
private readonly copyFile;
|
|
145
|
+
private readonly now;
|
|
146
|
+
private readonly log;
|
|
147
|
+
private currentKey;
|
|
148
|
+
private currentVersion;
|
|
149
|
+
private lastResolution;
|
|
150
|
+
private lastError;
|
|
151
|
+
private lastPrune;
|
|
152
|
+
private counters;
|
|
153
|
+
/** Version-read cache keyed on the source file's identity, so the (slow,
|
|
154
|
+
* synchronous) `--version` fallback for a package.json-less layout runs
|
|
155
|
+
* once per installed build, not once per spawn. */
|
|
156
|
+
private versionCache;
|
|
157
|
+
private pruneInFlight;
|
|
158
|
+
constructor(opts: ClaudeBinaryRetainerOptions);
|
|
159
|
+
/** The default retain dir for an agent: under its gitignored state dir. */
|
|
160
|
+
static defaultDir(projectDir: string): string;
|
|
161
|
+
/**
|
|
162
|
+
* Resolve the path to launch for `configuredPath`. Synchronous; copies only
|
|
163
|
+
* when a new version is seen. Never throws — every failure is a fallback
|
|
164
|
+
* to the original path with a reason.
|
|
165
|
+
*/
|
|
166
|
+
resolve(configuredPath: string): RetainResolution;
|
|
167
|
+
private accept;
|
|
168
|
+
private copyInto;
|
|
169
|
+
private removeTmp;
|
|
170
|
+
private touchLastUsed;
|
|
171
|
+
/** The directory this process has most recently launched from (null = never resolved). */
|
|
172
|
+
current(): {
|
|
173
|
+
key: string;
|
|
174
|
+
version: string | null;
|
|
175
|
+
path: string;
|
|
176
|
+
} | null;
|
|
177
|
+
listRetained(): RetainedVersionEntry[];
|
|
178
|
+
/**
|
|
179
|
+
* Remove retained versions that are not current, have not been used within
|
|
180
|
+
* the grace window, and that NO live process maps. "Cannot tell" keeps.
|
|
181
|
+
*/
|
|
182
|
+
prune(): Promise<PruneResult>;
|
|
183
|
+
private pruneOnce;
|
|
184
|
+
status(): RetainerStatus;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=ClaudeBinaryRetainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeBinaryRetainer.d.ts","sourceRoot":"","sources":["../../src/core/ClaudeBinaryRetainer.ts"],"names":[],"mappings":"AAgDA,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8FAA8F;IAC9F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,sBAAsB,QAAqB,CAAC;AACzD,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAK7C,MAAM,MAAM,oBAAoB,GAC5B,UAAU,GACV,gBAAgB,GAChB,mBAAmB,GACnB,YAAY,GACZ,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GACnB,aAAa,CAAC;AAElB,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,IAAI,EAAE,MA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