@osfactory/otel-hook 0.14.0 → 0.14.1
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 +17 -3
- package/dist/{adapter-D5R8lhfl.d.ts → adapter-But5fFCk.d.ts} +8 -1
- package/dist/cli.js +210 -45
- package/dist/cli.js.map +1 -1
- package/dist/{export-destinations-DvoH4QOe.d.ts → export-destinations-8tNkIC8a.d.ts} +12 -4
- package/dist/{filesystem-store-B3CpiIRl.d.ts → filesystem-store-Z8XgDtFj.d.ts} +1 -1
- package/dist/{hook-DVK8Don-.d.ts → hook-D7XABd4f.d.ts} +17 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.js +211 -45
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +3 -3
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +6 -6
- package/dist/integration.js +188 -40
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-B3r6sZtC.d.ts → memory-gipZUiXP.d.ts} +1 -1
- package/dist/{payload-D4r71EL-.d.ts → payload-DWdx9yk3.d.ts} +1 -1
- package/dist/{ports-DhpSDIkp.d.ts → ports-qZTwK-z2.d.ts} +22 -2
- package/dist/providers.d.ts +7 -7
- package/dist/providers.js +22 -5
- package/dist/providers.js.map +1 -1
- package/dist/{registry-DOJh9mzB.d.ts → registry-D9rmMYxw.d.ts} +1 -1
- package/dist/runtime.d.ts +22 -7
- package/dist/runtime.js +154 -28
- package/dist/runtime.js.map +1 -1
- package/dist/state.d.ts +3 -3
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +2 -2
- package/dist/telemetry.js +26 -9
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +6 -6
- package/dist/testing.js +57 -8
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as DetectionPolicy } from './schema-oRsbo7WO.js';
|
|
2
2
|
import { OtelHookErrorInfo } from './errors.js';
|
|
3
|
-
import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-
|
|
3
|
+
import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-But5fFCk.js';
|
|
4
4
|
|
|
5
5
|
type DetectionCandidate = {
|
|
6
6
|
readonly adapter: ProviderAdapter;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as LogLevel, d as Logger, W as WorktreeLocator, S as SessionContextReader, h as SessionContextSegment } from './ports-
|
|
2
|
-
export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, g as SessionContextRequest, i as StateRecord, j as StateStore, k as StateValue, T as
|
|
3
|
-
export { D as DeterministicIdOptions, F as FixedClock, a as FixedClockOptions, I as InMemoryStateStore, b as InMemoryStateStoreOptions, L as LogRecord, R as RecordingLogger, c as RecordingTelemetrySink, d as RecordingTelemetrySinkOptions, e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, h as createNullTelemetrySink, i as createRandomIdGenerator, j as createRecordingLogger, k as createRecordingTelemetrySink, l as createSystemClock } from './memory-
|
|
4
|
-
export { C as CumulativeUsageSeries, D as DeliveryDurability, a as DeliveryOrigin, b as DeliveryResolution, c as DeliveryUnavailableReason, H as HookIngestInput, d as HookIngestOptions, e as HookIngestOutcome, O as OtelHook, f as OtelHookDependencies, R as ResolvedDeliveryIdentity, U as UsageObservation, g as UsageScope, h as classifyDurability, i as createOtelHook, j as hostDeliveryIdentity, k as isCommittable, r as resolveDeliveryIdentity, u as usageScopeSchema } from './hook-
|
|
1
|
+
import { c as LogLevel, d as Logger, W as WorktreeLocator, S as SessionContextReader, h as SessionContextSegment } from './ports-qZTwK-z2.js';
|
|
2
|
+
export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, g as SessionContextRequest, i as StateRecord, j as StateStore, k as StateValue, T as TelemetryEmitOptions, l as TelemetryEmitResult, m as TelemetrySink, n as appliedDeliverySchema, o as logLevelSchema, s as stateRecordSchema, p as stateValueSchema } from './ports-qZTwK-z2.js';
|
|
3
|
+
export { D as DeterministicIdOptions, F as FixedClock, a as FixedClockOptions, I as InMemoryStateStore, b as InMemoryStateStoreOptions, L as LogRecord, R as RecordingLogger, c as RecordingTelemetrySink, d as RecordingTelemetrySinkOptions, e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, h as createNullTelemetrySink, i as createRandomIdGenerator, j as createRecordingLogger, k as createRecordingTelemetrySink, l as createSystemClock } from './memory-gipZUiXP.js';
|
|
4
|
+
export { C as CumulativeUsageSeries, D as DeliveryDurability, a as DeliveryOrigin, b as DeliveryResolution, c as DeliveryUnavailableReason, H as HookIngestInput, d as HookIngestOptions, e as HookIngestOutcome, O as OtelHook, f as OtelHookDependencies, R as ResolvedDeliveryIdentity, U as UsageObservation, g as UsageScope, h as classifyDurability, i as createOtelHook, j as hostDeliveryIdentity, k as isCommittable, r as resolveDeliveryIdentity, u as usageScopeSchema } from './hook-D7XABd4f.js';
|
|
5
5
|
import { b as CanonicalEvent, u as TargetHint } from './events-fcomX6d5.js';
|
|
6
6
|
import { d as EventId } from './primitives-CJ8-rn-f.js';
|
|
7
7
|
import { P as PrivacyService } from './service-DySC7KQM.js';
|
|
@@ -10,10 +10,10 @@ import './errors.js';
|
|
|
10
10
|
import './taxonomy-DwhTtuWd.js';
|
|
11
11
|
import './schema-oRsbo7WO.js';
|
|
12
12
|
import './identity-BrVBs901.js';
|
|
13
|
-
import './adapter-
|
|
13
|
+
import './adapter-But5fFCk.js';
|
|
14
14
|
import './policy-CimmCfRp.js';
|
|
15
15
|
import './content-M9xIKG7h.js';
|
|
16
|
-
import './registry-
|
|
16
|
+
import './registry-D9rmMYxw.js';
|
|
17
17
|
|
|
18
18
|
declare const createNullLogger: () => Logger;
|
|
19
19
|
type StderrLoggerOptions = {
|
|
@@ -60,6 +60,14 @@ declare const createStderrLogger: (options?: StderrLoggerOptions) => Logger;
|
|
|
60
60
|
* does not skip past it to an enclosing repository that the event did not
|
|
61
61
|
* target. A repository that cannot be named costs only `mainRoot`.
|
|
62
62
|
*
|
|
63
|
+
* The repository's `origin` remote is read on request only
|
|
64
|
+
* ({@link WorktreeLocator.originRepositoryKey}), from the `config` file of the
|
|
65
|
+
* repository's common git dir — the git dir itself when there is no `commondir`.
|
|
66
|
+
* It is reduced to its repository key at once (`normalizeRepositoryKey`), so the
|
|
67
|
+
* URL itself, with any credentials in it, never leaves this module. Includes,
|
|
68
|
+
* `insteadOf` rewrites and per-worktree config are not followed: a remote that
|
|
69
|
+
* needs them names no key, which is the safe answer for routing.
|
|
70
|
+
*
|
|
63
71
|
* Everything is bounded: walk depth, bytes read per file, and cache size. Every
|
|
64
72
|
* failure is `undefined`; nothing throws.
|
|
65
73
|
*/
|
|
@@ -73,6 +81,13 @@ declare const parseHeadBranch: (head: string) => string | undefined;
|
|
|
73
81
|
declare const parseGitDirFile: (content: string, worktreeRoot: string) => string | undefined;
|
|
74
82
|
/** A `commondir` file → the common git dir it names, resolved against the git dir. */
|
|
75
83
|
declare const parseCommonDirFile: (content: string, gitDir: string) => string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* The first `url` of `[remote "origin"]` in a git `config` file's text, or
|
|
86
|
+
* `undefined`. Section and key names are case-insensitive as in git; the
|
|
87
|
+
* subsection name is not. A final line without its newline may be cut by the
|
|
88
|
+
* read bound, so it is not trusted.
|
|
89
|
+
*/
|
|
90
|
+
declare const parseOriginRemoteUrl: (content: string) => string | undefined;
|
|
76
91
|
type FilesystemWorktreeLocatorOptions = {
|
|
77
92
|
/** Monotonic milliseconds for cache expiry. Defaults to `performance.now()`. */
|
|
78
93
|
readonly monotonicMillis?: () => number;
|
|
@@ -209,4 +224,4 @@ type DirectorySessionContextReaderOptions = {
|
|
|
209
224
|
*/
|
|
210
225
|
declare const createDirectorySessionContextReader: (options: DirectorySessionContextReaderOptions) => SessionContextReader;
|
|
211
226
|
|
|
212
|
-
export { DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS, DEFAULT_SESSION_CONTEXT_MAX_BYTES, DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, type DirectorySessionContextReaderOptions, type FilesystemWorktreeLocatorOptions, LogLevel, Logger, MAX_SESSION_CONTEXT_SEGMENTS, MAX_WORKTREE_WALK_DEPTH, type ResolveEventTargetsInput, type ResolveEventTargetsResult, SESSION_CONTEXT_AGENT_TOOLS, SESSION_CONTEXT_FILE_VERSION, SessionContextReader, SessionContextSegment, type StderrLoggerOptions, WorktreeLocator, createDirectorySessionContextReader, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, isReservedSessionContextKey, isSessionContextFileName, parseCommonDirFile, parseGitDirFile, parseHeadBranch, parseSessionContextFile, resolveEventTargets, sanitizeSessionContextAttributes, segmentInForce, sessionContextAgentTool, sessionContextFilePath, stampSessionContext };
|
|
227
|
+
export { DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS, DEFAULT_SESSION_CONTEXT_MAX_BYTES, DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, type DirectorySessionContextReaderOptions, type FilesystemWorktreeLocatorOptions, LogLevel, Logger, MAX_SESSION_CONTEXT_SEGMENTS, MAX_WORKTREE_WALK_DEPTH, type ResolveEventTargetsInput, type ResolveEventTargetsResult, SESSION_CONTEXT_AGENT_TOOLS, SESSION_CONTEXT_FILE_VERSION, SessionContextReader, SessionContextSegment, type StderrLoggerOptions, WorktreeLocator, createDirectorySessionContextReader, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, isReservedSessionContextKey, isSessionContextFileName, parseCommonDirFile, parseGitDirFile, parseHeadBranch, parseOriginRemoteUrl, parseSessionContextFile, resolveEventTargets, sanitizeSessionContextAttributes, segmentInForce, sessionContextAgentTool, sessionContextFilePath, stampSessionContext };
|
package/dist/runtime.js
CHANGED
|
@@ -2920,6 +2920,28 @@ var classifyDurability = (input) => {
|
|
|
2920
2920
|
};
|
|
2921
2921
|
var isCommittable = (durability) => durability !== "lost";
|
|
2922
2922
|
var MAX_ERROR_EVENTS = 8;
|
|
2923
|
+
var resolveWorkspaceRepositoryKey = async (locator, directory, budgetMillis) => {
|
|
2924
|
+
if (locator?.originRepositoryKey === void 0) {
|
|
2925
|
+
return void 0;
|
|
2926
|
+
}
|
|
2927
|
+
let timer;
|
|
2928
|
+
const deadline = new Promise((resolve3) => {
|
|
2929
|
+
timer = setTimeout(() => resolve3(void 0), Math.max(0, budgetMillis));
|
|
2930
|
+
timer.unref?.();
|
|
2931
|
+
});
|
|
2932
|
+
try {
|
|
2933
|
+
return await Promise.race([
|
|
2934
|
+
locator.originRepositoryKey(directory).catch(() => void 0),
|
|
2935
|
+
deadline
|
|
2936
|
+
]);
|
|
2937
|
+
} catch {
|
|
2938
|
+
return void 0;
|
|
2939
|
+
} finally {
|
|
2940
|
+
if (timer !== void 0) {
|
|
2941
|
+
clearTimeout(timer);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2923
2945
|
var collectContentFacts = (event2) => {
|
|
2924
2946
|
const facts = [];
|
|
2925
2947
|
const push = (fact) => {
|
|
@@ -3563,7 +3585,8 @@ var createOtelHook = (deps) => {
|
|
|
3563
3585
|
kind: "ready",
|
|
3564
3586
|
batch: batch2,
|
|
3565
3587
|
dropped: screened.dropped,
|
|
3566
|
-
...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints }
|
|
3588
|
+
...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints },
|
|
3589
|
+
...parsed.workspaceDirectory === void 0 ? {} : { workspaceDirectory: parsed.workspaceDirectory }
|
|
3567
3590
|
};
|
|
3568
3591
|
};
|
|
3569
3592
|
let prepared;
|
|
@@ -3631,11 +3654,19 @@ var createOtelHook = (deps) => {
|
|
|
3631
3654
|
batch,
|
|
3632
3655
|
!suppress && batch.length > 0 && deps.sessionContext !== void 0 ? await readSessionContext(deps.sessionContext, detection.providerId, identity.sessionId) : void 0
|
|
3633
3656
|
);
|
|
3657
|
+
const workspaceRepositoryKey = !suppress && batch.length > 0 && deps.routeByWorkspaceRepository === true && prepared.workspaceDirectory !== void 0 ? await resolveWorkspaceRepositoryKey(
|
|
3658
|
+
deps.worktreeLocator,
|
|
3659
|
+
prepared.workspaceDirectory,
|
|
3660
|
+
deps.targetResolutionBudgetMillis ?? DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS
|
|
3661
|
+
) : void 0;
|
|
3634
3662
|
let emitted = 0;
|
|
3635
3663
|
let exportRejected = 0;
|
|
3636
3664
|
if (!suppress && batch.length > 0) {
|
|
3637
3665
|
try {
|
|
3638
|
-
const result = await deps.sink.emit(
|
|
3666
|
+
const result = await deps.sink.emit(
|
|
3667
|
+
batch,
|
|
3668
|
+
workspaceRepositoryKey === void 0 ? void 0 : { workspaceRepositoryKey }
|
|
3669
|
+
);
|
|
3639
3670
|
emitted = result.accepted;
|
|
3640
3671
|
exportRejected = result.rejected;
|
|
3641
3672
|
diagnostics.push(...result.errors);
|
|
@@ -3694,7 +3725,8 @@ var createOtelHook = (deps) => {
|
|
|
3694
3725
|
durability,
|
|
3695
3726
|
dropped,
|
|
3696
3727
|
hookResponse: hookResponseFor(adapter, detection, "attributed", void 0, emitted, diagnostics),
|
|
3697
|
-
diagnostics
|
|
3728
|
+
diagnostics,
|
|
3729
|
+
...workspaceRepositoryKey === void 0 ? {} : { workspaceRepositoryKey }
|
|
3698
3730
|
};
|
|
3699
3731
|
} catch (thrown) {
|
|
3700
3732
|
const info = errorInfoFromThrown(thrown, { code: "internal-error", phase: "parsing" });
|
|
@@ -3793,15 +3825,16 @@ var MAX_WORKTREE_WALK_DEPTH = 128;
|
|
|
3793
3825
|
var MAX_GIT_FILE_BYTES = 4096;
|
|
3794
3826
|
var MAX_CACHE_ENTRIES = 1024;
|
|
3795
3827
|
var DEFAULT_WORKTREE_CACHE_TTL_MILLIS = 5e3;
|
|
3828
|
+
var MAX_GIT_CONFIG_BYTES = 64 * 1024;
|
|
3796
3829
|
var MAX_BRANCH_NAME_LENGTH = 255;
|
|
3797
3830
|
var ABSENT = Object.freeze({ kind: "absent" });
|
|
3798
3831
|
var INVALID = Object.freeze({ kind: "invalid" });
|
|
3799
|
-
var readBounded2 = async (filePath) => {
|
|
3832
|
+
var readBounded2 = async (filePath, maxBytes = MAX_GIT_FILE_BYTES) => {
|
|
3800
3833
|
let handle;
|
|
3801
3834
|
try {
|
|
3802
3835
|
handle = await open2(filePath, "r");
|
|
3803
|
-
const buffer = Buffer.alloc(
|
|
3804
|
-
const { bytesRead } = await handle.read(buffer, 0,
|
|
3836
|
+
const buffer = Buffer.alloc(maxBytes);
|
|
3837
|
+
const { bytesRead } = await handle.read(buffer, 0, maxBytes, 0);
|
|
3805
3838
|
return buffer.subarray(0, bytesRead).toString("utf8");
|
|
3806
3839
|
} catch {
|
|
3807
3840
|
return void 0;
|
|
@@ -3829,6 +3862,60 @@ var parseGitDirFile = (content, worktreeRoot) => {
|
|
|
3829
3862
|
);
|
|
3830
3863
|
};
|
|
3831
3864
|
var parseCommonDirFile = (content, gitDir) => resolveGitPath(firstLine(content), gitDir);
|
|
3865
|
+
var unquoteConfigValue = (raw) => {
|
|
3866
|
+
let value = "";
|
|
3867
|
+
let quoted = false;
|
|
3868
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
3869
|
+
const char = raw[index];
|
|
3870
|
+
if (char === "\\") {
|
|
3871
|
+
const next = raw[index + 1];
|
|
3872
|
+
if (next === void 0) {
|
|
3873
|
+
return void 0;
|
|
3874
|
+
}
|
|
3875
|
+
value += next === "n" ? "\n" : next === "t" ? " " : next;
|
|
3876
|
+
index += 1;
|
|
3877
|
+
} else if (char === '"') {
|
|
3878
|
+
quoted = !quoted;
|
|
3879
|
+
} else if (!quoted && (char === "#" || char === ";")) {
|
|
3880
|
+
break;
|
|
3881
|
+
} else {
|
|
3882
|
+
value += char;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
return quoted ? void 0 : value.trim();
|
|
3886
|
+
};
|
|
3887
|
+
var parseOriginRemoteUrl = (content) => {
|
|
3888
|
+
const lines = content.split(/\r?\n/);
|
|
3889
|
+
if (!content.endsWith("\n")) {
|
|
3890
|
+
lines.pop();
|
|
3891
|
+
}
|
|
3892
|
+
let inOrigin = false;
|
|
3893
|
+
for (const rawLine of lines) {
|
|
3894
|
+
const line = rawLine.trim();
|
|
3895
|
+
if (line.startsWith("[")) {
|
|
3896
|
+
const close = line.indexOf("]");
|
|
3897
|
+
const header = close === -1 ? "" : line.slice(1, close).trim();
|
|
3898
|
+
const rest = close === -1 ? "" : line.slice(close + 1).trim();
|
|
3899
|
+
inOrigin = /^remote\s+"origin"$/i.test(header) && header.endsWith('"origin"') || header.toLowerCase() === "remote.origin";
|
|
3900
|
+
if (!inOrigin || rest.length === 0 || rest.startsWith("#") || rest.startsWith(";")) {
|
|
3901
|
+
continue;
|
|
3902
|
+
}
|
|
3903
|
+
const entry2 = /^url\s*=(.*)$/i.exec(rest);
|
|
3904
|
+
if (entry2 !== null) {
|
|
3905
|
+
return unquoteConfigValue(entry2[1] ?? "");
|
|
3906
|
+
}
|
|
3907
|
+
continue;
|
|
3908
|
+
}
|
|
3909
|
+
if (!inOrigin) {
|
|
3910
|
+
continue;
|
|
3911
|
+
}
|
|
3912
|
+
const entry = /^url\s*=(.*)$/i.exec(line);
|
|
3913
|
+
if (entry !== null) {
|
|
3914
|
+
return unquoteConfigValue(entry[1] ?? "");
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
return void 0;
|
|
3918
|
+
};
|
|
3832
3919
|
var isMissing = async (filePath) => {
|
|
3833
3920
|
try {
|
|
3834
3921
|
await lstat(filePath);
|
|
@@ -3849,11 +3936,15 @@ var repositoryOf = async (worktreeRoot, gitDir) => {
|
|
|
3849
3936
|
const commonDirFile = path3.join(gitDir, "commondir");
|
|
3850
3937
|
const content = await readBounded2(commonDirFile);
|
|
3851
3938
|
if (content === void 0) {
|
|
3852
|
-
return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot } : { kind: "linked" };
|
|
3939
|
+
return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot, configDir: gitDir } : { kind: "linked" };
|
|
3853
3940
|
}
|
|
3854
3941
|
const commonDir = parseCommonDirFile(content, gitDir);
|
|
3855
3942
|
const mainRoot = commonDir !== void 0 && path3.basename(commonDir) === ".git" && await isDirectory(commonDir) ? path3.dirname(commonDir) : void 0;
|
|
3856
|
-
return {
|
|
3943
|
+
return {
|
|
3944
|
+
kind: "linked",
|
|
3945
|
+
...mainRoot === void 0 ? {} : { mainRoot },
|
|
3946
|
+
...commonDir === void 0 ? {} : { configDir: commonDir }
|
|
3947
|
+
};
|
|
3857
3948
|
};
|
|
3858
3949
|
var probeDirectory = async (directory) => {
|
|
3859
3950
|
const dotGit = path3.join(directory, ".git");
|
|
@@ -3878,12 +3969,21 @@ var probeDirectory = async (directory) => {
|
|
|
3878
3969
|
return INVALID;
|
|
3879
3970
|
}
|
|
3880
3971
|
const branch = parseHeadBranch(head);
|
|
3881
|
-
const repository = info.isDirectory() ? { kind: "main", mainRoot: directory } : await repositoryOf(directory, gitDir);
|
|
3972
|
+
const { configDir, ...repository } = info.isDirectory() ? { kind: "main", mainRoot: directory, configDir: gitDir } : await repositoryOf(directory, gitDir);
|
|
3882
3973
|
return {
|
|
3883
3974
|
kind: "worktree",
|
|
3884
|
-
located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository }
|
|
3975
|
+
located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository },
|
|
3976
|
+
configDir: configDir ?? ""
|
|
3885
3977
|
};
|
|
3886
3978
|
};
|
|
3979
|
+
var readOriginRepositoryKey = async (configDir) => {
|
|
3980
|
+
if (configDir.length === 0) {
|
|
3981
|
+
return void 0;
|
|
3982
|
+
}
|
|
3983
|
+
const content = await readBounded2(path3.join(configDir, "config"), MAX_GIT_CONFIG_BYTES);
|
|
3984
|
+
const url = content === void 0 ? void 0 : parseOriginRemoteUrl(content);
|
|
3985
|
+
return url === void 0 ? void 0 : normalizeRepositoryKey(url);
|
|
3986
|
+
};
|
|
3887
3987
|
var createFilesystemWorktreeLocator = (options = {}) => {
|
|
3888
3988
|
const now = options.monotonicMillis ?? (() => performance.now());
|
|
3889
3989
|
const ttl = options.cacheTtlMillis ?? DEFAULT_WORKTREE_CACHE_TTL_MILLIS;
|
|
@@ -3901,32 +4001,57 @@ var createFilesystemWorktreeLocator = (options = {}) => {
|
|
|
3901
4001
|
cache.set(directory, { at, probe });
|
|
3902
4002
|
return probe;
|
|
3903
4003
|
};
|
|
3904
|
-
const
|
|
3905
|
-
|
|
3906
|
-
|
|
4004
|
+
const remoteCache = /* @__PURE__ */ new Map();
|
|
4005
|
+
const cachedOriginKey = (configDir) => {
|
|
4006
|
+
const hit = remoteCache.get(configDir);
|
|
4007
|
+
const at = now();
|
|
4008
|
+
if (hit !== void 0 && at - hit.at <= ttl) {
|
|
4009
|
+
return hit.key;
|
|
4010
|
+
}
|
|
4011
|
+
if (remoteCache.size >= MAX_CACHE_ENTRIES) {
|
|
4012
|
+
remoteCache.clear();
|
|
4013
|
+
}
|
|
4014
|
+
const key = readOriginRepositoryKey(configDir).catch(() => void 0);
|
|
4015
|
+
remoteCache.set(configDir, { at, key });
|
|
4016
|
+
return key;
|
|
4017
|
+
};
|
|
4018
|
+
const findWorktree = async (absolutePath) => {
|
|
4019
|
+
if (!path3.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
|
|
4020
|
+
return void 0;
|
|
4021
|
+
}
|
|
4022
|
+
let directory = path3.resolve(absolutePath);
|
|
4023
|
+
for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
|
|
4024
|
+
const probe = await cachedProbe(directory);
|
|
4025
|
+
if (probe.kind === "worktree") {
|
|
4026
|
+
return probe;
|
|
4027
|
+
}
|
|
4028
|
+
if (probe.kind === "invalid") {
|
|
3907
4029
|
return void 0;
|
|
3908
4030
|
}
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
if (probe.kind === "worktree") {
|
|
3913
|
-
return probe.located;
|
|
3914
|
-
}
|
|
3915
|
-
if (probe.kind === "invalid") {
|
|
3916
|
-
return void 0;
|
|
3917
|
-
}
|
|
3918
|
-
const parent = path3.dirname(directory);
|
|
3919
|
-
if (parent === directory) {
|
|
3920
|
-
return void 0;
|
|
3921
|
-
}
|
|
3922
|
-
directory = parent;
|
|
4031
|
+
const parent = path3.dirname(directory);
|
|
4032
|
+
if (parent === directory) {
|
|
4033
|
+
return void 0;
|
|
3923
4034
|
}
|
|
4035
|
+
directory = parent;
|
|
4036
|
+
}
|
|
4037
|
+
return void 0;
|
|
4038
|
+
};
|
|
4039
|
+
const locate = async (absolutePath) => {
|
|
4040
|
+
try {
|
|
4041
|
+
return (await findWorktree(absolutePath))?.located;
|
|
4042
|
+
} catch {
|
|
3924
4043
|
return void 0;
|
|
4044
|
+
}
|
|
4045
|
+
};
|
|
4046
|
+
const originRepositoryKey = async (absolutePath) => {
|
|
4047
|
+
try {
|
|
4048
|
+
const probe = await findWorktree(absolutePath);
|
|
4049
|
+
return probe === void 0 ? void 0 : await cachedOriginKey(probe.configDir);
|
|
3925
4050
|
} catch {
|
|
3926
4051
|
return void 0;
|
|
3927
4052
|
}
|
|
3928
4053
|
};
|
|
3929
|
-
return { locate };
|
|
4054
|
+
return { locate, originRepositoryKey };
|
|
3930
4055
|
};
|
|
3931
4056
|
export {
|
|
3932
4057
|
DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS,
|
|
@@ -3961,6 +4086,7 @@ export {
|
|
|
3961
4086
|
parseCommonDirFile,
|
|
3962
4087
|
parseGitDirFile,
|
|
3963
4088
|
parseHeadBranch,
|
|
4089
|
+
parseOriginRemoteUrl,
|
|
3964
4090
|
parseSessionContextFile,
|
|
3965
4091
|
resolveDeliveryIdentity,
|
|
3966
4092
|
resolveEventTargets,
|