@probelabs/visor 0.1.146-ee → 0.1.147-ee
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/ai-review-service.d.ts.map +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/github-auth.d.ts +40 -0
- package/dist/github-auth.d.ts.map +1 -1
- package/dist/index.js +719 -329
- package/dist/sandbox/bubblewrap-sandbox.d.ts +2 -1
- package/dist/sandbox/bubblewrap-sandbox.d.ts.map +1 -1
- package/dist/sandbox/seatbelt-sandbox.d.ts +2 -1
- package/dist/sandbox/seatbelt-sandbox.d.ts.map +1 -1
- package/dist/scheduler/scheduler.d.ts.map +1 -1
- package/dist/sdk/{check-provider-registry-TH25S2OB.mjs → check-provider-registry-LBYIKFYM.mjs} +6 -6
- package/dist/sdk/{check-provider-registry-WSFL2SVQ.mjs → check-provider-registry-SCPM6DIT.mjs} +7 -7
- package/dist/sdk/{chunk-OM3WYVFI.mjs → chunk-4F5UVWAN.mjs} +2 -2
- package/dist/sdk/{chunk-OM3WYVFI.mjs.map → chunk-4F5UVWAN.mjs.map} +1 -1
- package/dist/sdk/{chunk-74YJMONB.mjs → chunk-EWGX7LI7.mjs} +69 -27
- package/dist/sdk/chunk-EWGX7LI7.mjs.map +1 -0
- package/dist/sdk/{chunk-I42ZCVA5.mjs → chunk-FBJ7MC7R.mjs} +3 -3
- package/dist/sdk/{chunk-3BOOHJI5.mjs → chunk-PNZH3JSI.mjs} +66 -24
- package/dist/sdk/chunk-PNZH3JSI.mjs.map +1 -0
- package/dist/sdk/{chunk-L3XPYQ6I.mjs → chunk-V2QW6ECX.mjs} +2 -2
- package/dist/sdk/{chunk-YOKAA4IU.mjs → chunk-XNTBSV6M.mjs} +2 -7
- package/dist/sdk/{chunk-YOKAA4IU.mjs.map → chunk-XNTBSV6M.mjs.map} +1 -1
- package/dist/sdk/{config-AAB2FL22.mjs → config-G5UU4WXT.mjs} +2 -2
- package/dist/sdk/{failure-condition-evaluator-O464EJMD.mjs → failure-condition-evaluator-FHNZL2US.mjs} +3 -3
- package/dist/sdk/github-auth-UPBBBOME.mjs +196 -0
- package/dist/sdk/github-auth-UPBBBOME.mjs.map +1 -0
- package/dist/sdk/{github-frontend-MSX6Q2WL.mjs → github-frontend-47EU2HBY.mjs} +3 -3
- package/dist/sdk/{host-5BJ25CUZ.mjs → host-GVR4UGZ3.mjs} +2 -2
- package/dist/sdk/{host-GA76UESS.mjs → host-KGN5OIAM.mjs} +2 -2
- package/dist/sdk/{loader-ZC5G3JGJ.mjs → loader-YSRMVXC3.mjs} +1 -1
- package/dist/sdk/{routing-RIHVCEIU.mjs → routing-CZ36LVVS.mjs} +4 -4
- package/dist/sdk/{schedule-tool-handler-NYL2ONJB.mjs → schedule-tool-handler-E7XHMU5G.mjs} +6 -6
- package/dist/sdk/{schedule-tool-handler-62K3NGH6.mjs → schedule-tool-handler-KFYNV7HL.mjs} +7 -7
- package/dist/sdk/sdk.js +51 -14
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +5 -5
- package/dist/sdk/{trace-helpers-QQSTZGDT.mjs → trace-helpers-EHDZ42HH.mjs} +2 -2
- package/dist/sdk/{workflow-check-provider-LVUUL2PZ.mjs → workflow-check-provider-5453TW65.mjs} +6 -6
- package/dist/sdk/{workflow-check-provider-XC7E5OFH.mjs → workflow-check-provider-BSUSPFOF.mjs} +7 -7
- package/dist/slack/socket-runner.d.ts.map +1 -1
- package/dist/test-runner/core/flow-stage.d.ts +2 -1
- package/dist/test-runner/core/flow-stage.d.ts.map +1 -1
- package/dist/test-runner/index.d.ts.map +1 -1
- package/dist/test-runner/validator.d.ts.map +1 -1
- package/dist/utils/worktree-manager.d.ts +11 -1
- package/dist/utils/worktree-manager.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/sdk/chunk-3BOOHJI5.mjs.map +0 -1
- package/dist/sdk/chunk-74YJMONB.mjs.map +0 -1
- /package/dist/sdk/{check-provider-registry-TH25S2OB.mjs.map → check-provider-registry-LBYIKFYM.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-WSFL2SVQ.mjs.map → check-provider-registry-SCPM6DIT.mjs.map} +0 -0
- /package/dist/sdk/{chunk-I42ZCVA5.mjs.map → chunk-FBJ7MC7R.mjs.map} +0 -0
- /package/dist/sdk/{chunk-L3XPYQ6I.mjs.map → chunk-V2QW6ECX.mjs.map} +0 -0
- /package/dist/sdk/{config-AAB2FL22.mjs.map → config-G5UU4WXT.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-O464EJMD.mjs.map → failure-condition-evaluator-FHNZL2US.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-MSX6Q2WL.mjs.map → github-frontend-47EU2HBY.mjs.map} +0 -0
- /package/dist/sdk/{host-5BJ25CUZ.mjs.map → host-GVR4UGZ3.mjs.map} +0 -0
- /package/dist/sdk/{host-GA76UESS.mjs.map → host-KGN5OIAM.mjs.map} +0 -0
- /package/dist/sdk/{loader-ZC5G3JGJ.mjs.map → loader-YSRMVXC3.mjs.map} +0 -0
- /package/dist/sdk/{routing-RIHVCEIU.mjs.map → routing-CZ36LVVS.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-62K3NGH6.mjs.map → schedule-tool-handler-E7XHMU5G.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-NYL2ONJB.mjs.map → schedule-tool-handler-KFYNV7HL.mjs.map} +0 -0
- /package/dist/sdk/{trace-helpers-QQSTZGDT.mjs.map → trace-helpers-EHDZ42HH.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-LVUUL2PZ.mjs.map → workflow-check-provider-5453TW65.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-XC7E5OFH.mjs.map → workflow-check-provider-BSUSPFOF.mjs.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ConfigManager,
|
|
3
3
|
VALID_EVENT_TRIGGERS,
|
|
4
4
|
init_config
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XNTBSV6M.mjs";
|
|
6
6
|
import "./chunk-NCWIZVOT.mjs";
|
|
7
7
|
import "./chunk-LW3INISN.mjs";
|
|
8
8
|
import "./chunk-SZXICFQ3.mjs";
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
ConfigManager,
|
|
14
14
|
VALID_EVENT_TRIGGERS
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=config-
|
|
16
|
+
//# sourceMappingURL=config-G5UU4WXT.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FailureConditionEvaluator,
|
|
3
3
|
init_failure_condition_evaluator
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-V2QW6ECX.mjs";
|
|
5
|
+
import "./chunk-4F5UVWAN.mjs";
|
|
6
6
|
import "./chunk-JL7JXCET.mjs";
|
|
7
7
|
import "./chunk-25IC7KXZ.mjs";
|
|
8
8
|
import "./chunk-LW3INISN.mjs";
|
|
@@ -14,4 +14,4 @@ init_failure_condition_evaluator();
|
|
|
14
14
|
export {
|
|
15
15
|
FailureConditionEvaluator
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=failure-condition-evaluator-
|
|
17
|
+
//# sourceMappingURL=failure-condition-evaluator-FHNZL2US.mjs.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_logger,
|
|
3
|
+
logger
|
|
4
|
+
} from "./chunk-SZXICFQ3.mjs";
|
|
5
|
+
import "./chunk-UCMJJ3IM.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__esm
|
|
8
|
+
} from "./chunk-J7LXIPZS.mjs";
|
|
9
|
+
|
|
10
|
+
// src/github-auth.ts
|
|
11
|
+
import { Octokit } from "@octokit/rest";
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
async function createAuthenticatedOctokit(options) {
|
|
15
|
+
const { token, appId, installationId, owner, repo } = options;
|
|
16
|
+
const privateKey = options.privateKey ? resolvePrivateKey(options.privateKey) : void 0;
|
|
17
|
+
if (appId && privateKey) {
|
|
18
|
+
const { createAppAuth } = await import("@octokit/auth-app");
|
|
19
|
+
let finalInstallationId;
|
|
20
|
+
if (installationId) {
|
|
21
|
+
finalInstallationId = parseInt(installationId, 10);
|
|
22
|
+
if (isNaN(finalInstallationId) || finalInstallationId <= 0) {
|
|
23
|
+
throw new Error("Invalid installation-id. It must be a positive integer.");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (!finalInstallationId && owner && repo) {
|
|
27
|
+
const appOctokit = new Octokit({
|
|
28
|
+
authStrategy: createAppAuth,
|
|
29
|
+
auth: { appId, privateKey }
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const { data: installation } = await appOctokit.rest.apps.getRepoInstallation({
|
|
33
|
+
owner,
|
|
34
|
+
repo
|
|
35
|
+
});
|
|
36
|
+
finalInstallationId = installation.id;
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"GitHub App installation ID could not be auto-detected. Provide --github-installation-id or ensure the app is installed on the repository."
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!finalInstallationId) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"GitHub App installation ID is required. Provide --github-installation-id or set owner/repo for auto-detection."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const octokit = new Octokit({
|
|
49
|
+
authStrategy: createAppAuth,
|
|
50
|
+
auth: {
|
|
51
|
+
appId,
|
|
52
|
+
privateKey,
|
|
53
|
+
installationId: finalInstallationId
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const authResult = await octokit.auth({ type: "installation" });
|
|
57
|
+
return {
|
|
58
|
+
octokit,
|
|
59
|
+
authType: "github-app",
|
|
60
|
+
token: authResult.token
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (token) {
|
|
64
|
+
return {
|
|
65
|
+
octokit: new Octokit({ auth: token }),
|
|
66
|
+
authType: "token",
|
|
67
|
+
token
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
function resolveAuthFromEnvironment() {
|
|
73
|
+
return {
|
|
74
|
+
token: process.env.GITHUB_TOKEN || process.env.GH_TOKEN,
|
|
75
|
+
appId: process.env.GITHUB_APP_ID,
|
|
76
|
+
privateKey: process.env.GITHUB_APP_PRIVATE_KEY,
|
|
77
|
+
installationId: process.env.GITHUB_APP_INSTALLATION_ID,
|
|
78
|
+
owner: process.env.GITHUB_REPOSITORY_OWNER || process.env.GITHUB_REPOSITORY?.split("/")[0],
|
|
79
|
+
repo: process.env.GITHUB_REPOSITORY?.split("/")[1]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function resolvePrivateKey(keyOrPath) {
|
|
83
|
+
if (keyOrPath.includes("-----BEGIN")) {
|
|
84
|
+
return keyOrPath;
|
|
85
|
+
}
|
|
86
|
+
const resolved = path.resolve(keyOrPath);
|
|
87
|
+
if (fs.existsSync(resolved)) {
|
|
88
|
+
return fs.readFileSync(resolved, "utf8");
|
|
89
|
+
}
|
|
90
|
+
return keyOrPath;
|
|
91
|
+
}
|
|
92
|
+
function injectGitHubCredentials(token) {
|
|
93
|
+
process.env.GITHUB_TOKEN = token;
|
|
94
|
+
process.env.GH_TOKEN = token;
|
|
95
|
+
const currentCount = parseInt(process.env.GIT_CONFIG_COUNT || "0", 10);
|
|
96
|
+
let base;
|
|
97
|
+
if (_authBase === void 0) {
|
|
98
|
+
base = currentCount;
|
|
99
|
+
} else if (_lastWrittenCount !== void 0 && currentCount !== _lastWrittenCount) {
|
|
100
|
+
base = currentCount;
|
|
101
|
+
} else {
|
|
102
|
+
base = _authBase;
|
|
103
|
+
}
|
|
104
|
+
_authBase = base;
|
|
105
|
+
const authUrl = `https://x-access-token:${token}@github.com/`;
|
|
106
|
+
process.env[`GIT_CONFIG_KEY_${base}`] = `url.${authUrl}.insteadOf`;
|
|
107
|
+
process.env[`GIT_CONFIG_VALUE_${base}`] = "https://github.com/";
|
|
108
|
+
process.env[`GIT_CONFIG_KEY_${base + 1}`] = `url.${authUrl}.insteadOf`;
|
|
109
|
+
process.env[`GIT_CONFIG_VALUE_${base + 1}`] = "git@github.com:";
|
|
110
|
+
const newCount = base + 2;
|
|
111
|
+
process.env.GIT_CONFIG_COUNT = String(newCount);
|
|
112
|
+
_lastWrittenCount = newCount;
|
|
113
|
+
}
|
|
114
|
+
function markTokenFresh() {
|
|
115
|
+
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
|
|
116
|
+
if (token) {
|
|
117
|
+
_cachedAppToken = { token, generatedAt: Date.now() };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function refreshGitHubCredentials() {
|
|
121
|
+
const appId = process.env.GITHUB_APP_ID;
|
|
122
|
+
const privateKey = process.env.GITHUB_APP_PRIVATE_KEY;
|
|
123
|
+
if (!appId || !privateKey) return;
|
|
124
|
+
const now = Date.now();
|
|
125
|
+
if (_cachedAppToken && now - _cachedAppToken.generatedAt < TOKEN_REFRESH_MS) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const opts = resolveAuthFromEnvironment();
|
|
130
|
+
const result = await createAuthenticatedOctokit(opts);
|
|
131
|
+
if (result && result.authType === "github-app") {
|
|
132
|
+
injectGitHubCredentials(result.token);
|
|
133
|
+
_cachedAppToken = { token: result.token, generatedAt: now };
|
|
134
|
+
logger.debug("[github-auth] Refreshed GitHub App installation token");
|
|
135
|
+
}
|
|
136
|
+
} catch (err) {
|
|
137
|
+
const age = _cachedAppToken ? `${Math.round((now - _cachedAppToken.generatedAt) / 6e4)}min old` : "no cached token";
|
|
138
|
+
logger.warn(
|
|
139
|
+
`[github-auth] Failed to refresh GitHub App token (${age}): ${err instanceof Error ? err.message : String(err)}. Child processes may fail with authentication errors.`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function startTokenRefreshTimer() {
|
|
144
|
+
if (_refreshTimer) return;
|
|
145
|
+
const appId = process.env.GITHUB_APP_ID;
|
|
146
|
+
const privateKey = process.env.GITHUB_APP_PRIVATE_KEY;
|
|
147
|
+
if (!appId || !privateKey) return;
|
|
148
|
+
_refreshTimer = setInterval(() => {
|
|
149
|
+
refreshGitHubCredentials().catch((err) => {
|
|
150
|
+
logger.warn(
|
|
151
|
+
`[github-auth] Background token refresh failed: ${err instanceof Error ? err.message : String(err)}`
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
}, TIMER_INTERVAL_MS);
|
|
155
|
+
_refreshTimer.unref();
|
|
156
|
+
logger.debug("[github-auth] Background token refresh timer started (every 30 min)");
|
|
157
|
+
}
|
|
158
|
+
function stopTokenRefreshTimer() {
|
|
159
|
+
if (_refreshTimer) {
|
|
160
|
+
clearInterval(_refreshTimer);
|
|
161
|
+
_refreshTimer = void 0;
|
|
162
|
+
logger.debug("[github-auth] Background token refresh timer stopped");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function _testSetCachedToken(token, generatedAt) {
|
|
166
|
+
if (token) {
|
|
167
|
+
_cachedAppToken = { token, generatedAt: generatedAt ?? Date.now() };
|
|
168
|
+
} else {
|
|
169
|
+
_cachedAppToken = void 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function _testGetCachedToken() {
|
|
173
|
+
return _cachedAppToken;
|
|
174
|
+
}
|
|
175
|
+
var _authBase, _lastWrittenCount, _cachedAppToken, TOKEN_REFRESH_MS, _refreshTimer, TIMER_INTERVAL_MS;
|
|
176
|
+
var init_github_auth = __esm({
|
|
177
|
+
"src/github-auth.ts"() {
|
|
178
|
+
init_logger();
|
|
179
|
+
TOKEN_REFRESH_MS = 45 * 60 * 1e3;
|
|
180
|
+
TIMER_INTERVAL_MS = 30 * 60 * 1e3;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
init_github_auth();
|
|
184
|
+
export {
|
|
185
|
+
_testGetCachedToken,
|
|
186
|
+
_testSetCachedToken,
|
|
187
|
+
createAuthenticatedOctokit,
|
|
188
|
+
injectGitHubCredentials,
|
|
189
|
+
markTokenFresh,
|
|
190
|
+
refreshGitHubCredentials,
|
|
191
|
+
resolveAuthFromEnvironment,
|
|
192
|
+
resolvePrivateKey,
|
|
193
|
+
startTokenRefreshTimer,
|
|
194
|
+
stopTokenRefreshTimer
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=github-auth-UPBBBOME.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/github-auth.ts"],"sourcesContent":["import { Octokit } from '@octokit/rest';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { logger } from './logger';\n\n/**\n * Options for GitHub authentication.\n * Supports both personal access token and GitHub App authentication.\n */\nexport interface GitHubAuthOptions {\n /** Personal access token or fine-grained token */\n token?: string;\n /** GitHub App ID */\n appId?: string;\n /** GitHub App private key (PEM content or file path) */\n privateKey?: string;\n /** GitHub App installation ID (auto-detected if omitted) */\n installationId?: string;\n /** Repository owner (for auto-detecting installation ID) */\n owner?: string;\n /** Repository name (for auto-detecting installation ID) */\n repo?: string;\n}\n\n/**\n * Result of successful GitHub authentication.\n */\nexport interface GitHubAuthResult {\n /** Authenticated Octokit instance */\n octokit: Octokit;\n /** Authentication method used */\n authType: 'github-app' | 'token';\n /** Raw token string for environment propagation */\n token: string;\n}\n\n/**\n * Create an authenticated Octokit instance.\n * Returns undefined if no credentials are provided (auth is optional in CLI mode).\n *\n * For token auth: uses the token directly.\n * For GitHub App auth: creates JWT-authenticated client, resolves installation ID,\n * then extracts an installation access token for environment propagation.\n */\nexport async function createAuthenticatedOctokit(\n options: GitHubAuthOptions\n): Promise<GitHubAuthResult | undefined> {\n const { token, appId, installationId, owner, repo } = options;\n const privateKey = options.privateKey ? resolvePrivateKey(options.privateKey) : undefined;\n\n // Prefer GitHub App authentication if app credentials are provided\n if (appId && privateKey) {\n const { createAppAuth } = await import('@octokit/auth-app');\n\n let finalInstallationId: number | undefined;\n\n if (installationId) {\n finalInstallationId = parseInt(installationId, 10);\n if (isNaN(finalInstallationId) || finalInstallationId <= 0) {\n throw new Error('Invalid installation-id. It must be a positive integer.');\n }\n }\n\n // Auto-detect installation ID if not provided\n if (!finalInstallationId && owner && repo) {\n const appOctokit = new Octokit({\n authStrategy: createAppAuth,\n auth: { appId, privateKey },\n });\n\n try {\n const { data: installation } = await appOctokit.rest.apps.getRepoInstallation({\n owner,\n repo,\n });\n finalInstallationId = installation.id;\n } catch {\n throw new Error(\n 'GitHub App installation ID could not be auto-detected. ' +\n 'Provide --github-installation-id or ensure the app is installed on the repository.'\n );\n }\n }\n\n if (!finalInstallationId) {\n throw new Error(\n 'GitHub App installation ID is required. Provide --github-installation-id or set owner/repo for auto-detection.'\n );\n }\n\n // Create the authenticated Octokit instance\n const octokit = new Octokit({\n authStrategy: createAppAuth,\n auth: {\n appId,\n privateKey,\n installationId: finalInstallationId,\n },\n });\n\n // Extract the installation access token for environment propagation\n const authResult = (await octokit.auth({ type: 'installation' })) as { token: string };\n\n return {\n octokit,\n authType: 'github-app',\n token: authResult.token,\n };\n }\n\n // Fall back to token authentication\n if (token) {\n return {\n octokit: new Octokit({ auth: token }),\n authType: 'token',\n token,\n };\n }\n\n // No credentials provided\n return undefined;\n}\n\n/**\n * Resolve GitHub auth options from environment variables.\n * Used as fallback when no explicit CLI arguments are provided.\n */\nexport function resolveAuthFromEnvironment(): GitHubAuthOptions {\n return {\n token: process.env.GITHUB_TOKEN || process.env.GH_TOKEN,\n appId: process.env.GITHUB_APP_ID,\n privateKey: process.env.GITHUB_APP_PRIVATE_KEY,\n installationId: process.env.GITHUB_APP_INSTALLATION_ID,\n owner: process.env.GITHUB_REPOSITORY_OWNER || process.env.GITHUB_REPOSITORY?.split('/')[0],\n repo: process.env.GITHUB_REPOSITORY?.split('/')[1],\n };\n}\n\n/**\n * Resolve private key — supports both inline PEM content and file paths.\n */\nexport function resolvePrivateKey(keyOrPath: string): string {\n if (keyOrPath.includes('-----BEGIN')) {\n return keyOrPath;\n }\n const resolved = path.resolve(keyOrPath);\n if (fs.existsSync(resolved)) {\n return fs.readFileSync(resolved, 'utf8');\n }\n // Return as-is and let the auth library handle errors\n return keyOrPath;\n}\n\n// Track our auth entries position so repeated calls replace instead of stacking.\n// _authBase: the GIT_CONFIG index where our 2 auth entries start.\n// _lastWrittenCount: what we last set GIT_CONFIG_COUNT to (detects external changes).\nlet _authBase: number | undefined;\nlet _lastWrittenCount: number | undefined;\n\n/**\n * Inject GitHub credentials into process.env for child processes.\n *\n * Sets GITHUB_TOKEN/GH_TOKEN for gh CLI, and configures git HTTPS auth\n * via GIT_CONFIG_COUNT/KEY/VALUE env vars so `git clone`, `git push`, etc.\n * work automatically against github.com without any local git config.\n *\n * Uses git's GIT_CONFIG_COUNT mechanism (git 2.31+, March 2021):\n * - No temp files or global config mutation\n * - Inherited by all child processes automatically\n * - Works regardless of local git configuration\n *\n * Safe to call multiple times (e.g. on token refresh) — replaces previous entries.\n */\nexport function injectGitHubCredentials(token: string): void {\n // Set for gh CLI and general GitHub API usage\n process.env.GITHUB_TOKEN = token;\n process.env.GH_TOKEN = token;\n\n const currentCount = parseInt(process.env.GIT_CONFIG_COUNT || '0', 10);\n\n // Determine where to write our 2 auth entries:\n // - First call: append after any pre-existing entries\n // - Subsequent calls with unchanged count: overwrite at same position\n // - If count changed externally: someone added entries, append after them\n let base: number;\n if (_authBase === undefined) {\n base = currentCount;\n } else if (_lastWrittenCount !== undefined && currentCount !== _lastWrittenCount) {\n base = currentCount;\n } else {\n base = _authBase;\n }\n _authBase = base;\n\n // Configure git HTTPS auth via url.<base>.insteadOf\n const authUrl = `https://x-access-token:${token}@github.com/`;\n\n // Rewrite HTTPS URLs\n process.env[`GIT_CONFIG_KEY_${base}`] = `url.${authUrl}.insteadOf`;\n process.env[`GIT_CONFIG_VALUE_${base}`] = 'https://github.com/';\n\n // Rewrite SSH-style URLs (git@github.com:org/repo)\n process.env[`GIT_CONFIG_KEY_${base + 1}`] = `url.${authUrl}.insteadOf`;\n process.env[`GIT_CONFIG_VALUE_${base + 1}`] = 'git@github.com:';\n\n const newCount = base + 2;\n process.env.GIT_CONFIG_COUNT = String(newCount);\n _lastWrittenCount = newCount;\n}\n\n/**\n * Mark the current token as freshly generated (for use after initial startup auth).\n * Prevents the first refreshGitHubCredentials() call from unnecessarily regenerating.\n */\nexport function markTokenFresh(): void {\n const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;\n if (token) {\n _cachedAppToken = { token, generatedAt: Date.now() };\n }\n}\n\n// Cached token with generation timestamp for expiry checks\nlet _cachedAppToken: { token: string; generatedAt: number } | undefined;\n\n// Installation tokens live 1 hour; refresh after 45 minutes.\n// Using 45 min (not 50) leaves a 15-minute buffer for long-running tasks\n// that start right before a refresh cycle.\nconst TOKEN_REFRESH_MS = 45 * 60 * 1000;\n\n// Background refresh timer\nlet _refreshTimer: ReturnType<typeof setInterval> | undefined;\n\n// How often the background timer checks (30 minutes)\nconst TIMER_INTERVAL_MS = 30 * 60 * 1000;\n\n/**\n * Refresh GitHub App installation credentials if they are about to expire.\n *\n * No-op when:\n * - No GitHub App credentials are configured (GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY)\n * - The current token was generated less than 45 minutes ago\n *\n * Call this before each execution in long-running processes (Slack bot, scheduler)\n * to ensure child processes always have a valid token for git/gh operations.\n */\nexport async function refreshGitHubCredentials(): Promise<void> {\n // Quick check: do we have App credentials?\n const appId = process.env.GITHUB_APP_ID;\n const privateKey = process.env.GITHUB_APP_PRIVATE_KEY;\n if (!appId || !privateKey) return;\n\n // Skip if cached token is still fresh\n const now = Date.now();\n if (_cachedAppToken && now - _cachedAppToken.generatedAt < TOKEN_REFRESH_MS) {\n return;\n }\n\n try {\n const opts = resolveAuthFromEnvironment();\n const result = await createAuthenticatedOctokit(opts);\n if (result && result.authType === 'github-app') {\n injectGitHubCredentials(result.token);\n _cachedAppToken = { token: result.token, generatedAt: now };\n logger.debug('[github-auth] Refreshed GitHub App installation token');\n }\n } catch (err) {\n const age = _cachedAppToken\n ? `${Math.round((now - _cachedAppToken.generatedAt) / 60000)}min old`\n : 'no cached token';\n logger.warn(\n `[github-auth] Failed to refresh GitHub App token (${age}): ${err instanceof Error ? err.message : String(err)}. ` +\n 'Child processes may fail with authentication errors.'\n );\n }\n}\n\n/**\n * Start a background timer that refreshes GitHub App tokens every 30 minutes.\n *\n * This ensures tokens stay fresh even during long-running tasks (e.g., an engineer\n * task that takes 40+ minutes). Without this, a token generated at startup could\n * expire mid-execution of a child process.\n *\n * The timer is unref'd so it doesn't prevent Node from exiting.\n * Call stopTokenRefreshTimer() on shutdown.\n */\nexport function startTokenRefreshTimer(): void {\n if (_refreshTimer) return; // Already running\n\n // Only start if we have App credentials\n const appId = process.env.GITHUB_APP_ID;\n const privateKey = process.env.GITHUB_APP_PRIVATE_KEY;\n if (!appId || !privateKey) return;\n\n _refreshTimer = setInterval(() => {\n refreshGitHubCredentials().catch(err => {\n logger.warn(\n `[github-auth] Background token refresh failed: ${err instanceof Error ? err.message : String(err)}`\n );\n });\n }, TIMER_INTERVAL_MS);\n\n // Don't prevent Node from exiting\n _refreshTimer.unref();\n\n logger.debug('[github-auth] Background token refresh timer started (every 30 min)');\n}\n\n/**\n * Stop the background token refresh timer.\n */\nexport function stopTokenRefreshTimer(): void {\n if (_refreshTimer) {\n clearInterval(_refreshTimer);\n _refreshTimer = undefined;\n logger.debug('[github-auth] Background token refresh timer stopped');\n }\n}\n\n/** Visible for testing: override the cached token state. */\nexport function _testSetCachedToken(token: string | undefined, generatedAt?: number): void {\n if (token) {\n _cachedAppToken = { token, generatedAt: generatedAt ?? Date.now() };\n } else {\n _cachedAppToken = undefined;\n }\n}\n\n/** Visible for testing: get the current cached token info. */\nexport function _testGetCachedToken(): { token: string; generatedAt: number } | undefined {\n return _cachedAppToken;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
failure_condition_evaluator_exports,
|
|
11
11
|
init_failure_condition_evaluator
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-V2QW6ECX.mjs";
|
|
13
|
+
import "./chunk-4F5UVWAN.mjs";
|
|
14
14
|
import "./chunk-JL7JXCET.mjs";
|
|
15
15
|
import "./chunk-25IC7KXZ.mjs";
|
|
16
16
|
import "./chunk-LW3INISN.mjs";
|
|
@@ -1353,4 +1353,4 @@ init_github_frontend();
|
|
|
1353
1353
|
export {
|
|
1354
1354
|
GitHubFrontend
|
|
1355
1355
|
};
|
|
1356
|
-
//# sourceMappingURL=github-frontend-
|
|
1356
|
+
//# sourceMappingURL=github-frontend-47EU2HBY.mjs.map
|
|
@@ -21,7 +21,7 @@ var init_host = __esm({
|
|
|
21
21
|
const { NdjsonSink } = await import("./ndjson-sink-FD2PSXGD.mjs");
|
|
22
22
|
this.frontends.push(new NdjsonSink(spec.config));
|
|
23
23
|
} else if (spec.name === "github") {
|
|
24
|
-
const { GitHubFrontend } = await import("./github-frontend-
|
|
24
|
+
const { GitHubFrontend } = await import("./github-frontend-47EU2HBY.mjs");
|
|
25
25
|
this.frontends.push(new GitHubFrontend());
|
|
26
26
|
} else if (spec.name === "slack") {
|
|
27
27
|
const { SlackFrontend } = await import("./slack-frontend-TZU2HIK7.mjs");
|
|
@@ -60,4 +60,4 @@ init_host();
|
|
|
60
60
|
export {
|
|
61
61
|
FrontendsHost
|
|
62
62
|
};
|
|
63
|
-
//# sourceMappingURL=host-
|
|
63
|
+
//# sourceMappingURL=host-GVR4UGZ3.mjs.map
|
|
@@ -21,7 +21,7 @@ var init_host = __esm({
|
|
|
21
21
|
const { NdjsonSink } = await import("./ndjson-sink-FD2PSXGD.mjs");
|
|
22
22
|
this.frontends.push(new NdjsonSink(spec.config));
|
|
23
23
|
} else if (spec.name === "github") {
|
|
24
|
-
const { GitHubFrontend } = await import("./github-frontend-
|
|
24
|
+
const { GitHubFrontend } = await import("./github-frontend-47EU2HBY.mjs");
|
|
25
25
|
this.frontends.push(new GitHubFrontend());
|
|
26
26
|
} else if (spec.name === "slack") {
|
|
27
27
|
const { SlackFrontend } = await import("./slack-frontend-TZU2HIK7.mjs");
|
|
@@ -60,4 +60,4 @@ init_host();
|
|
|
60
60
|
export {
|
|
61
61
|
FrontendsHost
|
|
62
62
|
};
|
|
63
|
-
//# sourceMappingURL=host-
|
|
63
|
+
//# sourceMappingURL=host-KGN5OIAM.mjs.map
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
evaluateTransitions,
|
|
5
5
|
handleRouting,
|
|
6
6
|
init_routing
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-FBJ7MC7R.mjs";
|
|
8
|
+
import "./chunk-V2QW6ECX.mjs";
|
|
9
|
+
import "./chunk-4F5UVWAN.mjs";
|
|
10
10
|
import "./chunk-JL7JXCET.mjs";
|
|
11
11
|
import "./chunk-ZUEQNCKB.mjs";
|
|
12
12
|
import "./chunk-25IC7KXZ.mjs";
|
|
@@ -22,4 +22,4 @@ export {
|
|
|
22
22
|
evaluateTransitions,
|
|
23
23
|
handleRouting
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=routing-
|
|
25
|
+
//# sourceMappingURL=routing-CZ36LVVS.mjs.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
extractSlackContext,
|
|
7
7
|
init_schedule_tool_handler,
|
|
8
8
|
isScheduleToolCall
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PNZH3JSI.mjs";
|
|
10
10
|
import "./chunk-KFKHU6CM.mjs";
|
|
11
11
|
import "./chunk-M3BYMES6.mjs";
|
|
12
12
|
import "./chunk-LG4AUKHB.mjs";
|
|
@@ -14,12 +14,12 @@ import "./chunk-B7BVQM5K.mjs";
|
|
|
14
14
|
import "./chunk-XXAEN5KU.mjs";
|
|
15
15
|
import "./chunk-GEW6LS32.mjs";
|
|
16
16
|
import "./chunk-DIND4ZCV.mjs";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-XNTBSV6M.mjs";
|
|
18
18
|
import "./chunk-NCWIZVOT.mjs";
|
|
19
19
|
import "./chunk-XKCER23W.mjs";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-FBJ7MC7R.mjs";
|
|
21
|
+
import "./chunk-V2QW6ECX.mjs";
|
|
22
|
+
import "./chunk-4F5UVWAN.mjs";
|
|
23
23
|
import "./chunk-JL7JXCET.mjs";
|
|
24
24
|
import "./chunk-ZUEQNCKB.mjs";
|
|
25
25
|
import "./chunk-25IC7KXZ.mjs";
|
|
@@ -37,4 +37,4 @@ export {
|
|
|
37
37
|
extractSlackContext,
|
|
38
38
|
isScheduleToolCall
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=schedule-tool-handler-
|
|
40
|
+
//# sourceMappingURL=schedule-tool-handler-E7XHMU5G.mjs.map
|
|
@@ -6,20 +6,20 @@ import {
|
|
|
6
6
|
extractSlackContext,
|
|
7
7
|
init_schedule_tool_handler,
|
|
8
8
|
isScheduleToolCall
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EWGX7LI7.mjs";
|
|
10
|
+
import "./chunk-KFKHU6CM.mjs";
|
|
10
11
|
import "./chunk-M3BYMES6.mjs";
|
|
11
12
|
import "./chunk-LG4AUKHB.mjs";
|
|
12
|
-
import "./chunk-KFKHU6CM.mjs";
|
|
13
13
|
import "./chunk-B7BVQM5K.mjs";
|
|
14
14
|
import "./chunk-XXAEN5KU.mjs";
|
|
15
15
|
import "./chunk-GEW6LS32.mjs";
|
|
16
16
|
import "./chunk-DIND4ZCV.mjs";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-XNTBSV6M.mjs";
|
|
18
18
|
import "./chunk-NCWIZVOT.mjs";
|
|
19
19
|
import "./chunk-XKCER23W.mjs";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-FBJ7MC7R.mjs";
|
|
21
|
+
import "./chunk-V2QW6ECX.mjs";
|
|
22
|
+
import "./chunk-4F5UVWAN.mjs";
|
|
23
23
|
import "./chunk-JL7JXCET.mjs";
|
|
24
24
|
import "./chunk-ZUEQNCKB.mjs";
|
|
25
25
|
import "./chunk-25IC7KXZ.mjs";
|
|
@@ -37,4 +37,4 @@ export {
|
|
|
37
37
|
extractSlackContext,
|
|
38
38
|
isScheduleToolCall
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=schedule-tool-handler-
|
|
40
|
+
//# sourceMappingURL=schedule-tool-handler-KFYNV7HL.mjs.map
|
package/dist/sdk/sdk.js
CHANGED
|
@@ -760,7 +760,7 @@ var require_package = __commonJS({
|
|
|
760
760
|
"@opentelemetry/sdk-node": "^0.203.0",
|
|
761
761
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
762
762
|
"@opentelemetry/semantic-conventions": "^1.30.1",
|
|
763
|
-
"@probelabs/probe": "^0.6.0-
|
|
763
|
+
"@probelabs/probe": "^0.6.0-rc262",
|
|
764
764
|
"@types/commander": "^2.12.0",
|
|
765
765
|
"@types/uuid": "^10.0.0",
|
|
766
766
|
acorn: "^8.16.0",
|
|
@@ -8501,12 +8501,15 @@ ${"=".repeat(60)}
|
|
|
8501
8501
|
if (!systemPrompt && schema !== "code-review") {
|
|
8502
8502
|
systemPrompt = "You are general assistant, follow user instructions.";
|
|
8503
8503
|
}
|
|
8504
|
+
log(
|
|
8505
|
+
`\u{1F527} AIReviewService config: allowEdit=${this.config.allowEdit}, allowBash=${this.config.allowBash}, promptType=${this.config.promptType}`
|
|
8506
|
+
);
|
|
8504
8507
|
const options = {
|
|
8505
8508
|
sessionId,
|
|
8506
8509
|
// Prefer config promptType, then env override, else fallback to code-review when schema is set
|
|
8507
8510
|
promptType: this.config.promptType && this.config.promptType.trim() ? this.config.promptType.trim() : explicitPromptType ? explicitPromptType : schema === "code-review" ? "code-review-template" : void 0,
|
|
8508
8511
|
allowEdit: false,
|
|
8509
|
-
//
|
|
8512
|
+
// Default: don't allow file modifications
|
|
8510
8513
|
debug: this.config.debug || false,
|
|
8511
8514
|
// Use systemPrompt (native in rc168+) with fallback to customPrompt for backward compat
|
|
8512
8515
|
systemPrompt: systemPrompt || this.config.systemPrompt || this.config.customPrompt
|
|
@@ -8595,6 +8598,9 @@ ${"=".repeat(60)}
|
|
|
8595
8598
|
if (this.config.model) {
|
|
8596
8599
|
options.model = this.config.model;
|
|
8597
8600
|
}
|
|
8601
|
+
log(
|
|
8602
|
+
`\u{1F527} ProbeAgent options: allowEdit=${options.allowEdit}, enableBash=${options.enableBash}, promptType=${options.promptType}`
|
|
8603
|
+
);
|
|
8598
8604
|
const agent = new import_probe2.ProbeAgent(options);
|
|
8599
8605
|
if (typeof agent.initialize === "function") {
|
|
8600
8606
|
await agent.initialize();
|
|
@@ -15543,14 +15549,9 @@ ${errors}`);
|
|
|
15543
15549
|
const { WorkflowRegistry: WorkflowRegistry2 } = await Promise.resolve().then(() => (init_workflow_registry(), workflow_registry_exports));
|
|
15544
15550
|
const registry = WorkflowRegistry2.getInstance();
|
|
15545
15551
|
for (const source of config.imports) {
|
|
15546
|
-
const results = await registry.import(source, { basePath, validate: true });
|
|
15552
|
+
const results = await registry.import(source, { basePath, validate: true, override: true });
|
|
15547
15553
|
for (const result of results) {
|
|
15548
15554
|
if (!result.valid && result.errors) {
|
|
15549
|
-
const isAlreadyExists = result.errors.every((e) => e.message.includes("already exists"));
|
|
15550
|
-
if (isAlreadyExists) {
|
|
15551
|
-
logger.debug(`Workflow from '${source}' already imported, skipping`);
|
|
15552
|
-
continue;
|
|
15553
|
-
}
|
|
15554
15555
|
const errors = result.errors.map((e) => ` ${e.path}: ${e.message}`).join("\n");
|
|
15555
15556
|
throw new Error(`Failed to import workflow from '${source}':
|
|
15556
15557
|
${errors}`);
|
|
@@ -45055,7 +45056,7 @@ var init_worktree_manager = __esm({
|
|
|
45055
45056
|
/**
|
|
45056
45057
|
* Get or create bare repository
|
|
45057
45058
|
*/
|
|
45058
|
-
async getOrCreateBareRepo(repository, repoUrl,
|
|
45059
|
+
async getOrCreateBareRepo(repository, repoUrl, _token, fetchDepth, cloneTimeoutMs) {
|
|
45059
45060
|
const reposDir = this.getReposDir();
|
|
45060
45061
|
const repoName = repository.replace(/\//g, "-");
|
|
45061
45062
|
const bareRepoPath = path20.join(reposDir, `${repoName}.git`);
|
|
@@ -45071,11 +45072,12 @@ var init_worktree_manager = __esm({
|
|
|
45071
45072
|
);
|
|
45072
45073
|
await fsp.rm(bareRepoPath, { recursive: true, force: true });
|
|
45073
45074
|
} else {
|
|
45075
|
+
await this.resetBareRepoRemoteUrl(bareRepoPath, repoUrl);
|
|
45074
45076
|
await this.updateBareRepo(bareRepoPath);
|
|
45075
45077
|
return bareRepoPath;
|
|
45076
45078
|
}
|
|
45077
45079
|
}
|
|
45078
|
-
const cloneUrl =
|
|
45080
|
+
const cloneUrl = repoUrl;
|
|
45079
45081
|
const redactedUrl = this.redactUrl(cloneUrl);
|
|
45080
45082
|
logger.info(
|
|
45081
45083
|
`Cloning bare repository: ${redactedUrl}${fetchDepth ? ` (depth: ${fetchDepth})` : ""}`
|
|
@@ -45156,6 +45158,33 @@ var init_worktree_manager = __esm({
|
|
|
45156
45158
|
return false;
|
|
45157
45159
|
}
|
|
45158
45160
|
}
|
|
45161
|
+
/**
|
|
45162
|
+
* Ensure the origin remote URL of a bare repo is a plain URL (no embedded token).
|
|
45163
|
+
*
|
|
45164
|
+
* Older bare repos may have been cloned with a token in the URL
|
|
45165
|
+
* (https://x-access-token:TOKEN@github.com/...). This causes stale-token
|
|
45166
|
+
* failures because GIT_CONFIG insteadOf rules can't rewrite URLs that
|
|
45167
|
+
* already have credentials. Resetting to the plain URL lets insteadOf
|
|
45168
|
+
* handle auth with the freshest token.
|
|
45169
|
+
*/
|
|
45170
|
+
async resetBareRepoRemoteUrl(bareRepoPath, plainRepoUrl) {
|
|
45171
|
+
try {
|
|
45172
|
+
const cmd = `git -C ${this.escapeShellArg(bareRepoPath)} remote set-url origin ${this.escapeShellArg(plainRepoUrl)}`;
|
|
45173
|
+
const result = await this.executeGitCommand(cmd, { timeout: 1e4 });
|
|
45174
|
+
if (result.exitCode !== 0) {
|
|
45175
|
+
logger.warn(
|
|
45176
|
+
`Failed to reset bare repo remote URL: ${result.stderr}. Git operations may fail with stale token if the URL has embedded credentials.`
|
|
45177
|
+
);
|
|
45178
|
+
} else {
|
|
45179
|
+
logger.debug(`Reset bare repo remote URL to plain URL for ${bareRepoPath}`);
|
|
45180
|
+
}
|
|
45181
|
+
} catch (error) {
|
|
45182
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
45183
|
+
logger.warn(
|
|
45184
|
+
`Error resetting bare repo remote URL: ${msg}. Git operations may fail with stale token if the URL has embedded credentials.`
|
|
45185
|
+
);
|
|
45186
|
+
}
|
|
45187
|
+
}
|
|
45159
45188
|
/**
|
|
45160
45189
|
* Create a new worktree for the given repository/ref.
|
|
45161
45190
|
*
|
|
@@ -51210,10 +51239,12 @@ var init_bubblewrap_sandbox = __esm({
|
|
|
51210
51239
|
name;
|
|
51211
51240
|
config;
|
|
51212
51241
|
repoPath;
|
|
51213
|
-
|
|
51242
|
+
visorDistPath;
|
|
51243
|
+
constructor(name, config, repoPath, visorDistPath) {
|
|
51214
51244
|
this.name = name;
|
|
51215
51245
|
this.config = config;
|
|
51216
51246
|
this.repoPath = (0, import_path10.resolve)(repoPath);
|
|
51247
|
+
this.visorDistPath = (0, import_path10.resolve)(visorDistPath);
|
|
51217
51248
|
}
|
|
51218
51249
|
/**
|
|
51219
51250
|
* Check if bwrap binary is available on the system.
|
|
@@ -51294,6 +51325,8 @@ var init_bubblewrap_sandbox = __esm({
|
|
|
51294
51325
|
} else {
|
|
51295
51326
|
args.push("--bind", this.repoPath, workdir);
|
|
51296
51327
|
}
|
|
51328
|
+
const visorPath = this.config.visor_path || "/opt/visor";
|
|
51329
|
+
args.push("--ro-bind", this.visorDistPath, visorPath);
|
|
51297
51330
|
args.push("--chdir", workdir);
|
|
51298
51331
|
args.push("--unshare-pid");
|
|
51299
51332
|
args.push("--new-session");
|
|
@@ -51335,10 +51368,12 @@ var init_seatbelt_sandbox = __esm({
|
|
|
51335
51368
|
name;
|
|
51336
51369
|
config;
|
|
51337
51370
|
repoPath;
|
|
51338
|
-
|
|
51371
|
+
visorDistPath;
|
|
51372
|
+
constructor(name, config, repoPath, visorDistPath) {
|
|
51339
51373
|
this.name = name;
|
|
51340
51374
|
this.config = config;
|
|
51341
51375
|
this.repoPath = (0, import_fs7.realpathSync)((0, import_path11.resolve)(repoPath));
|
|
51376
|
+
this.visorDistPath = (0, import_fs7.realpathSync)((0, import_path11.resolve)(visorDistPath));
|
|
51342
51377
|
}
|
|
51343
51378
|
/**
|
|
51344
51379
|
* Check if sandbox-exec binary is available on the system.
|
|
@@ -51439,6 +51474,8 @@ var init_seatbelt_sandbox = __esm({
|
|
|
51439
51474
|
if (!this.config.read_only) {
|
|
51440
51475
|
lines.push(`(allow file-write* (subpath "${repoPath}"))`);
|
|
51441
51476
|
}
|
|
51477
|
+
const visorDistPath = this.escapePath(this.visorDistPath);
|
|
51478
|
+
lines.push(`(allow file-read* (subpath "${visorDistPath}"))`);
|
|
51442
51479
|
if (this.config.network !== false) {
|
|
51443
51480
|
lines.push("(allow network*)");
|
|
51444
51481
|
}
|
|
@@ -51511,13 +51548,13 @@ var init_sandbox_manager = __esm({
|
|
|
51511
51548
|
const mode = config.compose ? "compose" : "image";
|
|
51512
51549
|
if (config.engine === "bubblewrap") {
|
|
51513
51550
|
const { BubblewrapSandbox: BubblewrapSandbox2 } = (init_bubblewrap_sandbox(), __toCommonJS(bubblewrap_sandbox_exports));
|
|
51514
|
-
const instance = new BubblewrapSandbox2(name, config, this.repoPath);
|
|
51551
|
+
const instance = new BubblewrapSandbox2(name, config, this.repoPath, this.visorDistPath);
|
|
51515
51552
|
this.instances.set(name, instance);
|
|
51516
51553
|
return instance;
|
|
51517
51554
|
}
|
|
51518
51555
|
if (config.engine === "seatbelt") {
|
|
51519
51556
|
const { SeatbeltSandbox: SeatbeltSandbox2 } = (init_seatbelt_sandbox(), __toCommonJS(seatbelt_sandbox_exports));
|
|
51520
|
-
const instance = new SeatbeltSandbox2(name, config, this.repoPath);
|
|
51557
|
+
const instance = new SeatbeltSandbox2(name, config, this.repoPath, this.visorDistPath);
|
|
51521
51558
|
this.instances.set(name, instance);
|
|
51522
51559
|
return instance;
|
|
51523
51560
|
}
|