@pensar/apex 1.7.0 → 1.8.0-canary.bca11887
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/build/agent-dta6yxmv.js +19 -0
- package/build/{agent-beywhvf3.js → agent-mwyqsgkv.js} +7 -7
- package/build/{auth-wvh553ea.js → auth-v45k7kwg.js} +4 -4
- package/build/{authentication-ec7trwb4.js → authentication-x05ezcbv.js} +7 -7
- package/build/{blackboxAgent-ng2t2p2x.js → blackboxAgent-mh034gj9.js} +8 -8
- package/build/{blackboxPentest-rwyjy4kq.js → blackboxPentest-q1metac4.js} +12 -12
- package/build/{cli-vvyq7ace.js → cli-2fyhd535.js} +1 -1
- package/build/{cli-5m0347h3.js → cli-5m7g7shj.js} +1 -1
- package/build/{cli-40ef01tb.js → cli-be5vjpky.js} +1 -1
- package/build/{cli-836bfgxg.js → cli-bra9dqvr.js} +1 -1
- package/build/{cli-06zt0g1a.js → cli-dtskes40.js} +2 -2
- package/build/{cli-zr7sg2m2.js → cli-ewz82ybz.js} +2 -2
- package/build/{cli-q2dty8g4.js → cli-h5ymnpn0.js} +1 -1
- package/build/{cli-xtqm11qt.js → cli-j0j2b0zg.js} +1 -1
- package/build/{cli-rc7hyq7e.js → cli-nbywpmx0.js} +2 -2
- package/build/{cli-nqx9y9ds.js → cli-p3sa63tj.js} +1 -1
- package/build/{cli-x3k26g1t.js → cli-q2j5rn5v.js} +146 -123
- package/build/{cli-09prdch1.js → cli-rj7c5e8g.js} +6 -6
- package/build/{cli-gr3zncst.js → cli-x1vsazs1.js} +1 -1
- package/build/{cli-r879p2yz.js → cli-zbwgjkvp.js} +1 -1
- package/build/cli.js +31 -27
- package/build/{fixes-1z283wdz.js → fixes-aqv4bd63.js} +4 -4
- package/build/{index-1p5bg26t.js → index-4eh25n0z.js} +4 -4
- package/build/{index-a4ydz3dd.js → index-hxcvfnfn.js} +7 -7
- package/build/{index-5a173a2k.js → index-nxcmwwmr.js} +6 -6
- package/build/{index-py7gtxez.js → index-pa1xft87.js} +2 -2
- package/build/{index-j3hw6d4w.js → index-x7v5084y.js} +10 -10
- package/build/{issues-trbzy8n0.js → issues-bq6rczst.js} +4 -4
- package/build/{logs-c88md0h3.js → logs-8swbm9c4.js} +4 -4
- package/build/{offesecAgent-ahcz5hcx.js → offesecAgent-4pznagm5.js} +7 -7
- package/build/{pentest-4932ke3a.js → pentest-b9ez419x.js} +12 -12
- package/build/{pentests-re8dzxt9.js → pentests-hh8sc5q2.js} +4 -4
- package/build/{projects-dqp4m0ws.js → projects-8a1mbpmq.js} +4 -4
- package/build/{targetedPentest-de8a67va.js → targetedPentest-79n3c3dv.js} +8 -8
- package/build/{threatModel-waz866yk.js → threatModel-t7fdxzz4.js} +8 -8
- package/build/{uninstall-0bwz7jdn.js → uninstall-q13yf2s9.js} +1 -1
- package/package.json +1 -1
- package/build/agent-63cc9rpx.js +0 -19
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeAgent
|
|
3
|
+
} from "./cli-ewz82ybz.js";
|
|
4
|
+
import"./cli-q2j5rn5v.js";
|
|
5
|
+
import"./cli-tp1tqn3k.js";
|
|
6
|
+
import"./cli-p3sa63tj.js";
|
|
7
|
+
import"./cli-3y0dgy56.js";
|
|
8
|
+
import"./cli-nbywpmx0.js";
|
|
9
|
+
import"./cli-0ghkg3w6.js";
|
|
10
|
+
import"./cli-j0j2b0zg.js";
|
|
11
|
+
import"./cli-h5ymnpn0.js";
|
|
12
|
+
import"./cli-gpnb45ck.js";
|
|
13
|
+
import"./cli-be5vjpky.js";
|
|
14
|
+
import"./cli-zbwgjkvp.js";
|
|
15
|
+
import"./cli-03z6pswp.js";
|
|
16
|
+
import"./cli-8rxa073f.js";
|
|
17
|
+
export {
|
|
18
|
+
CodeAgent
|
|
19
|
+
};
|
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
} from "./cli-0fy9j5dw.js";
|
|
4
4
|
import {
|
|
5
5
|
OffensiveSecurityAgent
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-q2j5rn5v.js";
|
|
7
7
|
import"./cli-tp1tqn3k.js";
|
|
8
|
-
import"./cli-
|
|
8
|
+
import"./cli-p3sa63tj.js";
|
|
9
9
|
import"./cli-3y0dgy56.js";
|
|
10
10
|
import {
|
|
11
11
|
hasToolCall
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-nbywpmx0.js";
|
|
13
13
|
import {
|
|
14
14
|
tool
|
|
15
15
|
} from "./cli-0ghkg3w6.js";
|
|
16
|
-
import"./cli-
|
|
17
|
-
import"./cli-
|
|
16
|
+
import"./cli-j0j2b0zg.js";
|
|
17
|
+
import"./cli-h5ymnpn0.js";
|
|
18
18
|
import"./cli-gpnb45ck.js";
|
|
19
|
-
import"./cli-
|
|
20
|
-
import"./cli-
|
|
19
|
+
import"./cli-be5vjpky.js";
|
|
20
|
+
import"./cli-zbwgjkvp.js";
|
|
21
21
|
import"./cli-03z6pswp.js";
|
|
22
22
|
import"./cli-8rxa073f.js";
|
|
23
23
|
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
pollWorkOSToken,
|
|
9
9
|
selectWorkspace,
|
|
10
10
|
startDeviceFlow
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-j0j2b0zg.js";
|
|
12
12
|
import {
|
|
13
13
|
config,
|
|
14
14
|
getPensarApiUrl,
|
|
15
15
|
getPensarConsoleUrl
|
|
16
|
-
} from "./cli-
|
|
17
|
-
import"./cli-
|
|
18
|
-
import"./cli-
|
|
16
|
+
} from "./cli-h5ymnpn0.js";
|
|
17
|
+
import"./cli-be5vjpky.js";
|
|
18
|
+
import"./cli-zbwgjkvp.js";
|
|
19
19
|
import {
|
|
20
20
|
__require
|
|
21
21
|
} from "./cli-8rxa073f.js";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OffensiveSecurityAgent
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-q2j5rn5v.js";
|
|
4
4
|
import {
|
|
5
5
|
detectOSAndEnhancePrompt
|
|
6
6
|
} from "./cli-tp1tqn3k.js";
|
|
7
|
-
import"./cli-
|
|
7
|
+
import"./cli-p3sa63tj.js";
|
|
8
8
|
import"./cli-3y0dgy56.js";
|
|
9
9
|
import {
|
|
10
10
|
hasToolCall
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-nbywpmx0.js";
|
|
12
12
|
import"./cli-0ghkg3w6.js";
|
|
13
|
-
import"./cli-
|
|
14
|
-
import"./cli-
|
|
13
|
+
import"./cli-j0j2b0zg.js";
|
|
14
|
+
import"./cli-h5ymnpn0.js";
|
|
15
15
|
import"./cli-gpnb45ck.js";
|
|
16
|
-
import"./cli-
|
|
17
|
-
import"./cli-
|
|
16
|
+
import"./cli-be5vjpky.js";
|
|
17
|
+
import"./cli-zbwgjkvp.js";
|
|
18
18
|
import"./cli-03z6pswp.js";
|
|
19
19
|
import"./cli-8rxa073f.js";
|
|
20
20
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlackboxAttackSurfaceAgent
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
3
|
+
} from "./cli-dtskes40.js";
|
|
4
|
+
import"./cli-q2j5rn5v.js";
|
|
5
5
|
import"./cli-tp1tqn3k.js";
|
|
6
|
-
import"./cli-
|
|
6
|
+
import"./cli-p3sa63tj.js";
|
|
7
7
|
import"./cli-3y0dgy56.js";
|
|
8
|
-
import"./cli-
|
|
8
|
+
import"./cli-nbywpmx0.js";
|
|
9
9
|
import"./cli-0ghkg3w6.js";
|
|
10
|
-
import"./cli-
|
|
11
|
-
import"./cli-
|
|
10
|
+
import"./cli-j0j2b0zg.js";
|
|
11
|
+
import"./cli-h5ymnpn0.js";
|
|
12
12
|
import"./cli-gpnb45ck.js";
|
|
13
|
-
import"./cli-
|
|
14
|
-
import"./cli-
|
|
13
|
+
import"./cli-be5vjpky.js";
|
|
14
|
+
import"./cli-zbwgjkvp.js";
|
|
15
15
|
import"./cli-03z6pswp.js";
|
|
16
16
|
import"./cli-8rxa073f.js";
|
|
17
17
|
export {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runPentestWorkflow
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
5
|
-
import"./cli-
|
|
3
|
+
} from "./cli-rj7c5e8g.js";
|
|
4
|
+
import"./cli-x1vsazs1.js";
|
|
5
|
+
import"./cli-5m7g7shj.js";
|
|
6
6
|
import"./cli-0fy9j5dw.js";
|
|
7
|
-
import"./cli-
|
|
7
|
+
import"./cli-dtskes40.js";
|
|
8
8
|
import"./cli-fw5r7pfj.js";
|
|
9
|
-
import"./cli-
|
|
10
|
-
import"./cli-
|
|
9
|
+
import"./cli-ewz82ybz.js";
|
|
10
|
+
import"./cli-q2j5rn5v.js";
|
|
11
11
|
import"./cli-tp1tqn3k.js";
|
|
12
|
-
import"./cli-
|
|
12
|
+
import"./cli-p3sa63tj.js";
|
|
13
13
|
import"./cli-3y0dgy56.js";
|
|
14
|
-
import"./cli-
|
|
14
|
+
import"./cli-nbywpmx0.js";
|
|
15
15
|
import"./cli-0ghkg3w6.js";
|
|
16
|
-
import"./cli-
|
|
17
|
-
import"./cli-
|
|
16
|
+
import"./cli-j0j2b0zg.js";
|
|
17
|
+
import"./cli-h5ymnpn0.js";
|
|
18
18
|
import"./cli-gpnb45ck.js";
|
|
19
|
-
import"./cli-
|
|
20
|
-
import"./cli-
|
|
19
|
+
import"./cli-be5vjpky.js";
|
|
20
|
+
import"./cli-zbwgjkvp.js";
|
|
21
21
|
import"./cli-03z6pswp.js";
|
|
22
22
|
import"./cli-8rxa073f.js";
|
|
23
23
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OffensiveSecurityAgent
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-q2j5rn5v.js";
|
|
4
4
|
import {
|
|
5
5
|
detectOSAndEnhancePrompt
|
|
6
6
|
} from "./cli-tp1tqn3k.js";
|
|
7
7
|
import {
|
|
8
8
|
hasToolCall,
|
|
9
9
|
stepCountIs
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-nbywpmx0.js";
|
|
11
11
|
|
|
12
12
|
// src/core/agents/specialized/attackSurface/blackboxAgent.ts
|
|
13
13
|
import { join } from "path";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OffensiveSecurityAgent
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-q2j5rn5v.js";
|
|
4
4
|
import {
|
|
5
5
|
stepCountIs
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-nbywpmx0.js";
|
|
7
7
|
|
|
8
8
|
// src/core/agents/specialized/codeAgent/prompts.ts
|
|
9
9
|
var CODE_AGENT_SYSTEM_PROMPT = `You are an expert coding agent with direct filesystem access. You will be given a specific objective — focus exclusively on completing it.
|
|
@@ -71,12 +71,12 @@ import {
|
|
|
71
71
|
} from "./cli-0ghkg3w6.js";
|
|
72
72
|
import {
|
|
73
73
|
signGatewayRequest
|
|
74
|
-
} from "./cli-
|
|
74
|
+
} from "./cli-j0j2b0zg.js";
|
|
75
75
|
import {
|
|
76
76
|
config,
|
|
77
77
|
ensureValidToken,
|
|
78
78
|
getPensarGatewayUrl
|
|
79
|
-
} from "./cli-
|
|
79
|
+
} from "./cli-h5ymnpn0.js";
|
|
80
80
|
import {
|
|
81
81
|
getModelInfo,
|
|
82
82
|
init_models
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
update,
|
|
17
17
|
write,
|
|
18
18
|
writeRaw
|
|
19
|
-
} from "./cli-
|
|
19
|
+
} from "./cli-p3sa63tj.js";
|
|
20
20
|
import {
|
|
21
21
|
parseTargetUrl
|
|
22
22
|
} from "./cli-3y0dgy56.js";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
require_tslib,
|
|
30
30
|
streamResponse,
|
|
31
31
|
toggleTool
|
|
32
|
-
} from "./cli-
|
|
32
|
+
} from "./cli-nbywpmx0.js";
|
|
33
33
|
import {
|
|
34
34
|
_enum,
|
|
35
35
|
_null,
|
|
@@ -57,15 +57,15 @@ import {
|
|
|
57
57
|
} from "./cli-0ghkg3w6.js";
|
|
58
58
|
import {
|
|
59
59
|
signGatewayRequest
|
|
60
|
-
} from "./cli-
|
|
60
|
+
} from "./cli-j0j2b0zg.js";
|
|
61
61
|
import {
|
|
62
62
|
config,
|
|
63
63
|
ensureValidToken,
|
|
64
64
|
getPensarApiUrl
|
|
65
|
-
} from "./cli-
|
|
65
|
+
} from "./cli-h5ymnpn0.js";
|
|
66
66
|
import {
|
|
67
67
|
getCurrentVersion
|
|
68
|
-
} from "./cli-
|
|
68
|
+
} from "./cli-zbwgjkvp.js";
|
|
69
69
|
import {
|
|
70
70
|
__commonJS,
|
|
71
71
|
__require,
|
|
@@ -119360,7 +119360,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
|
|
|
119360
119360
|
return threatModelLimiter(async () => {
|
|
119361
119361
|
if (ctx.abortSignal?.aborted)
|
|
119362
119362
|
return null;
|
|
119363
|
-
const { CodeAgent } = await import("./agent-
|
|
119363
|
+
const { CodeAgent } = await import("./agent-dta6yxmv.js");
|
|
119364
119364
|
const subagentId = `threat-model-${sanitize(input.appName)}-${sanitize(input.routePath)}`;
|
|
119365
119365
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
119366
119366
|
subagentId,
|
|
@@ -120049,7 +120049,7 @@ When to use delegate_to_auth_subagent vs authenticate_session:
|
|
|
120049
120049
|
if (credentials) {
|
|
120050
120050
|
ctx.session.credentialManager.addFromAuthCredentials(credentials);
|
|
120051
120051
|
}
|
|
120052
|
-
const { runAuthenticationAgent } = await import("./authentication-
|
|
120052
|
+
const { runAuthenticationAgent } = await import("./authentication-x05ezcbv.js");
|
|
120053
120053
|
const localBus = new AgentEventBus;
|
|
120054
120054
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
120055
120055
|
const result = await runAuthenticationAgent({
|
|
@@ -120962,7 +120962,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
120962
120962
|
});
|
|
120963
120963
|
if (cwd) {
|
|
120964
120964
|
try {
|
|
120965
|
-
const { WhiteboxAttackSurfaceAgent } = await import("./agent-
|
|
120965
|
+
const { WhiteboxAttackSurfaceAgent } = await import("./agent-mwyqsgkv.js");
|
|
120966
120966
|
const localBus = new AgentEventBus;
|
|
120967
120967
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
120968
120968
|
const agent = new WhiteboxAttackSurfaceAgent({
|
|
@@ -121011,7 +121011,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
121011
121011
|
}
|
|
121012
121012
|
}
|
|
121013
121013
|
try {
|
|
121014
|
-
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-
|
|
121014
|
+
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-mh034gj9.js");
|
|
121015
121015
|
const localBus = new AgentEventBus;
|
|
121016
121016
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
121017
121017
|
const agent = new BlackboxAttackSurfaceAgent({
|
|
@@ -121087,7 +121087,7 @@ Pass every target you want tested — the swarm handles concurrency automaticall
|
|
|
121087
121087
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
121088
121088
|
}),
|
|
121089
121089
|
execute: async ({ targets }) => {
|
|
121090
|
-
const { runPentestSwarm, DEFAULT_CONCURRENCY } = await import("./pentest-
|
|
121090
|
+
const { runPentestSwarm, DEFAULT_CONCURRENCY } = await import("./pentest-b9ez419x.js");
|
|
121091
121091
|
if (!ctx.model) {
|
|
121092
121092
|
return {
|
|
121093
121093
|
success: false,
|
|
@@ -121215,7 +121215,7 @@ Returns an array of results with the text output from each agent.`,
|
|
|
121215
121215
|
});
|
|
121216
121216
|
}
|
|
121217
121217
|
async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, name) {
|
|
121218
|
-
const { CodeAgent } = await import("./agent-
|
|
121218
|
+
const { CodeAgent } = await import("./agent-dta6yxmv.js");
|
|
121219
121219
|
const subagentId = `coding-agent-${agentIndex}`;
|
|
121220
121220
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
121221
121221
|
subagentId,
|
|
@@ -121276,7 +121276,7 @@ Omit \`cwd\` for blackbox mode (live target probing only).`,
|
|
|
121276
121276
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
121277
121277
|
}),
|
|
121278
121278
|
execute: async ({ target, cwd }) => {
|
|
121279
|
-
const { runPentestWorkflow: workflow } = await import("./pentest-
|
|
121279
|
+
const { runPentestWorkflow: workflow } = await import("./pentest-b9ez419x.js");
|
|
121280
121280
|
if (!ctx.model) {
|
|
121281
121281
|
return {
|
|
121282
121282
|
success: false,
|
|
@@ -125983,6 +125983,7 @@ class PersistentShell {
|
|
|
125983
125983
|
extraEnv;
|
|
125984
125984
|
current = null;
|
|
125985
125985
|
pendingCancel = null;
|
|
125986
|
+
writeChain = Promise.resolve();
|
|
125986
125987
|
constructor(opts) {
|
|
125987
125988
|
this.cwd = opts?.cwd;
|
|
125988
125989
|
this.extraEnv = opts?.env;
|
|
@@ -126110,129 +126111,151 @@ class PersistentShell {
|
|
|
126110
126111
|
return { stdout: "", stderr: "Shell has been disposed", exitCode: 1 };
|
|
126111
126112
|
}
|
|
126112
126113
|
if (abortSignal?.aborted) {
|
|
126113
|
-
return {
|
|
126114
|
-
stdout: "",
|
|
126115
|
-
stderr: "Command aborted",
|
|
126116
|
-
exitCode: 130
|
|
126117
|
-
};
|
|
126114
|
+
return { stdout: "", stderr: "Command aborted", exitCode: 130 };
|
|
126118
126115
|
}
|
|
126119
|
-
this.
|
|
126120
|
-
|
|
126121
|
-
|
|
126122
|
-
|
|
126123
|
-
|
|
126124
|
-
|
|
126125
|
-
|
|
126126
|
-
|
|
126127
|
-
|
|
126128
|
-
|
|
126129
|
-
|
|
126130
|
-
|
|
126131
|
-
|
|
126132
|
-
|
|
126133
|
-
|
|
126134
|
-
|
|
126135
|
-
|
|
126136
|
-
|
|
126137
|
-
|
|
126138
|
-
exitMarkerPrefix
|
|
126139
|
-
|
|
126140
|
-
|
|
126141
|
-
|
|
126142
|
-
|
|
126143
|
-
|
|
126144
|
-
|
|
126145
|
-
|
|
126146
|
-
|
|
126147
|
-
|
|
126148
|
-
|
|
126149
|
-
|
|
126150
|
-
|
|
126151
|
-
|
|
126152
|
-
resolve5(result);
|
|
126153
|
-
}
|
|
126154
|
-
};
|
|
126155
|
-
this.current = pending;
|
|
126156
|
-
this.pendingCancel = pending.resolve;
|
|
126157
|
-
let abortCleanup;
|
|
126158
|
-
if (abortSignal) {
|
|
126159
|
-
const onAbort = () => {
|
|
126160
|
-
if (resolved)
|
|
126161
|
-
return;
|
|
126162
|
-
pending.forcedExitCode = 130;
|
|
126163
|
-
pending.forcedStderrSuffix = pending.stderr ? `
|
|
126164
|
-
(aborted)` : "(aborted)";
|
|
126165
|
-
killDescendants(proc.pid, "SIGTERM");
|
|
126166
|
-
killEscalationTimer = setTimeout(() => {
|
|
126116
|
+
const release = await this.acquireTurn();
|
|
126117
|
+
try {
|
|
126118
|
+
if (this.disposed) {
|
|
126119
|
+
return { stdout: "", stderr: "Shell has been disposed", exitCode: 1 };
|
|
126120
|
+
}
|
|
126121
|
+
if (abortSignal?.aborted) {
|
|
126122
|
+
return { stdout: "", stderr: "Command aborted", exitCode: 130 };
|
|
126123
|
+
}
|
|
126124
|
+
this.ensureAlive();
|
|
126125
|
+
const proc = this.proc;
|
|
126126
|
+
if (!proc || !proc.stdin || !proc.stdout || !proc.stderr) {
|
|
126127
|
+
return { stdout: "", stderr: "Failed to spawn shell", exitCode: 1 };
|
|
126128
|
+
}
|
|
126129
|
+
return await new Promise((resolve5) => {
|
|
126130
|
+
let resolved = false;
|
|
126131
|
+
let timeoutTimer;
|
|
126132
|
+
let killEscalationTimer;
|
|
126133
|
+
let abortCleanup;
|
|
126134
|
+
const marker = `__APEX_${randomBytes(8).toString("hex")}__`;
|
|
126135
|
+
const exitMarkerPrefix = `${marker}_EXIT_`;
|
|
126136
|
+
const cutoverMarker = `${marker}_CUTOVER`;
|
|
126137
|
+
const pending = {
|
|
126138
|
+
streamedStdout: "",
|
|
126139
|
+
authoritativeStdout: "",
|
|
126140
|
+
cutoverSeen: false,
|
|
126141
|
+
cutoverMarker,
|
|
126142
|
+
stderr: "",
|
|
126143
|
+
stdoutTruncated: false,
|
|
126144
|
+
exitMarkerPrefix,
|
|
126145
|
+
onData,
|
|
126146
|
+
forcedExitCode: null,
|
|
126147
|
+
forcedStderrSuffix: null,
|
|
126148
|
+
resolve: (result) => {
|
|
126167
126149
|
if (resolved)
|
|
126168
126150
|
return;
|
|
126169
|
-
|
|
126170
|
-
|
|
126151
|
+
resolved = true;
|
|
126152
|
+
if (timeoutTimer)
|
|
126153
|
+
clearTimeout(timeoutTimer);
|
|
126154
|
+
if (killEscalationTimer)
|
|
126155
|
+
clearTimeout(killEscalationTimer);
|
|
126156
|
+
if (abortCleanup)
|
|
126157
|
+
abortCleanup();
|
|
126158
|
+
resolve5(result);
|
|
126159
|
+
}
|
|
126160
|
+
};
|
|
126161
|
+
this.current = pending;
|
|
126162
|
+
this.pendingCancel = pending.resolve;
|
|
126163
|
+
if (abortSignal) {
|
|
126164
|
+
const onAbort = () => {
|
|
126165
|
+
if (resolved)
|
|
126166
|
+
return;
|
|
126167
|
+
pending.forcedExitCode = 130;
|
|
126168
|
+
pending.forcedStderrSuffix = pending.stderr ? `
|
|
126169
|
+
(aborted)` : "(aborted)";
|
|
126170
|
+
killDescendants(proc.pid, "SIGTERM");
|
|
126171
|
+
killEscalationTimer = setTimeout(() => {
|
|
126171
126172
|
if (resolved)
|
|
126172
126173
|
return;
|
|
126173
|
-
|
|
126174
|
-
|
|
126175
|
-
|
|
126176
|
-
|
|
126177
|
-
|
|
126178
|
-
|
|
126179
|
-
|
|
126180
|
-
|
|
126181
|
-
|
|
126182
|
-
|
|
126183
|
-
|
|
126184
|
-
|
|
126185
|
-
|
|
126186
|
-
|
|
126187
|
-
|
|
126188
|
-
|
|
126189
|
-
|
|
126190
|
-
killEscalationTimer = setTimeout(() => {
|
|
126174
|
+
killDescendants(proc.pid, "SIGKILL");
|
|
126175
|
+
setTimeout(() => {
|
|
126176
|
+
if (resolved)
|
|
126177
|
+
return;
|
|
126178
|
+
pending.resolve({
|
|
126179
|
+
stdout: extractFallbackStdout(pending),
|
|
126180
|
+
stderr: (pending.stderr || "") + (pending.forcedStderrSuffix ?? ""),
|
|
126181
|
+
exitCode: 130
|
|
126182
|
+
});
|
|
126183
|
+
}, 2000);
|
|
126184
|
+
}, 500);
|
|
126185
|
+
};
|
|
126186
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
126187
|
+
abortCleanup = () => abortSignal.removeEventListener("abort", onAbort);
|
|
126188
|
+
}
|
|
126189
|
+
if (timeoutSeconds != null && timeoutSeconds > 0) {
|
|
126190
|
+
timeoutTimer = setTimeout(() => {
|
|
126191
126191
|
if (resolved)
|
|
126192
126192
|
return;
|
|
126193
|
-
|
|
126194
|
-
|
|
126193
|
+
pending.forcedExitCode = 124;
|
|
126194
|
+
killDescendants(proc.pid, "SIGTERM");
|
|
126195
|
+
killEscalationTimer = setTimeout(() => {
|
|
126195
126196
|
if (resolved)
|
|
126196
126197
|
return;
|
|
126197
|
-
|
|
126198
|
-
|
|
126199
|
-
|
|
126200
|
-
|
|
126201
|
-
|
|
126202
|
-
|
|
126203
|
-
|
|
126204
|
-
|
|
126205
|
-
|
|
126206
|
-
|
|
126207
|
-
|
|
126208
|
-
|
|
126209
|
-
|
|
126210
|
-
|
|
126211
|
-
|
|
126212
|
-
|
|
126198
|
+
killDescendants(proc.pid, "SIGKILL");
|
|
126199
|
+
setTimeout(() => {
|
|
126200
|
+
if (resolved)
|
|
126201
|
+
return;
|
|
126202
|
+
pending.resolve({
|
|
126203
|
+
stdout: extractFallbackStdout(pending),
|
|
126204
|
+
stderr: pending.stderr || "",
|
|
126205
|
+
exitCode: 124
|
|
126206
|
+
});
|
|
126207
|
+
}, 2000);
|
|
126208
|
+
}, 500);
|
|
126209
|
+
}, timeoutSeconds * 1000);
|
|
126210
|
+
}
|
|
126211
|
+
const tailCmd = hasStdbuf() ? `stdbuf -oL tail -n +1 -f -s 0.05 "$__APEX_OUT"` : `tail -n +1 -f -s 0.05 "$__APEX_OUT"`;
|
|
126212
|
+
const wrapped = [
|
|
126213
|
+
`__APEX_OUT=$(mktemp 2>/dev/null || echo /tmp/.apex_out_$$)`,
|
|
126214
|
+
`__APEX_ERR=$(mktemp 2>/dev/null || echo /tmp/.apex_err_$$)`,
|
|
126215
|
+
`${tailCmd} 2>/dev/null &`,
|
|
126216
|
+
`__APEX_TAIL=$!`,
|
|
126217
|
+
`{ ${command}
|
|
126213
126218
|
} </dev/null >"$__APEX_OUT" 2>"$__APEX_ERR"`,
|
|
126214
|
-
|
|
126215
|
-
|
|
126216
|
-
|
|
126217
|
-
|
|
126218
|
-
|
|
126219
|
-
|
|
126220
|
-
|
|
126221
|
-
|
|
126222
|
-
|
|
126223
|
-
|
|
126224
|
-
|
|
126219
|
+
`__APEX_EC=$?`,
|
|
126220
|
+
`sleep 0.1`,
|
|
126221
|
+
`kill "$__APEX_TAIL" 2>/dev/null`,
|
|
126222
|
+
`wait "$__APEX_TAIL" 2>/dev/null`,
|
|
126223
|
+
`printf '%s\\n' "${cutoverMarker}"`,
|
|
126224
|
+
`cat "$__APEX_OUT"`,
|
|
126225
|
+
`cat "$__APEX_ERR" >&2`,
|
|
126226
|
+
`rm -f "$__APEX_OUT" "$__APEX_ERR"`,
|
|
126227
|
+
`echo "${exitMarkerPrefix}$__APEX_EC"`,
|
|
126228
|
+
``
|
|
126229
|
+
].join(`
|
|
126225
126230
|
`);
|
|
126226
|
-
|
|
126227
|
-
|
|
126228
|
-
|
|
126229
|
-
|
|
126230
|
-
|
|
126231
|
-
|
|
126232
|
-
|
|
126233
|
-
|
|
126234
|
-
|
|
126231
|
+
try {
|
|
126232
|
+
proc.stdin.write(wrapped);
|
|
126233
|
+
} catch {
|
|
126234
|
+
pending.resolve({
|
|
126235
|
+
stdout: "",
|
|
126236
|
+
stderr: "Failed to write to shell stdin",
|
|
126237
|
+
exitCode: 1
|
|
126238
|
+
});
|
|
126239
|
+
}
|
|
126240
|
+
});
|
|
126241
|
+
} catch (e) {
|
|
126242
|
+
return {
|
|
126243
|
+
stdout: "",
|
|
126244
|
+
stderr: e instanceof Error ? e.message : String(e),
|
|
126245
|
+
exitCode: 1
|
|
126246
|
+
};
|
|
126247
|
+
} finally {
|
|
126248
|
+
release();
|
|
126249
|
+
}
|
|
126250
|
+
}
|
|
126251
|
+
async acquireTurn() {
|
|
126252
|
+
const myTurn = this.writeChain;
|
|
126253
|
+
let release;
|
|
126254
|
+
this.writeChain = new Promise((res) => {
|
|
126255
|
+
release = res;
|
|
126235
126256
|
});
|
|
126257
|
+
await myTurn;
|
|
126258
|
+
return release;
|
|
126236
126259
|
}
|
|
126237
126260
|
cancelCurrentCommand() {
|
|
126238
126261
|
const cmd = this.current;
|